Iterating List object in a JSP whose value coming from ViewAction class which is displaying proper.
Below is the jps code.
Add a default no-args Constructor to your Bean
Class.
The default no-args Constructor is called like that because it is the default: if you don't specify any Constructor, it is created automatically.
If instead you specify another Constructor, for example one with parameters like your, the no-args Constructor is not automatically created anymore, and you have to declare it explicitly if you need it.
Struts2 needs the no-args Constructor to create your beans.
For example, you could have a bean with a Constructor taking 10 parameters, and specify only one of them in the JSP page: Struts must be able to create the object and set the single field (through the Setter) without caring about the nine missing parameters.
You have to use Type Conversion, Provide following configuration in ViewCheckboxAction-conversion.properties file :
KeyProperty_beanList=rollnumber
Element_beanList=Bean
CreateIfNull_beanList=true
When submitting this via a form, the rollnumber is used as KeyProperty for the Bean instances in the beanList.You can use any other property for Key Property field. The value for name will be set to the MyBean instance with this special id. The List does not have null values added for unavailable id values. This approach avoids the risk of OutOfMemoryErrors!
<s:iterator value="beanList" id="bean">
<tr>
<td>
<input type="checkbox" name="subCheckBox" />
</td>
<td>
<s:textfield name="beanList(%{bean.rollnumber}).rollnumber" value="%{rollnumber}" theme="simple"/>
</td>
<td>
<s:textfield name="beanList(%{bean.rollnumber}).name" value="%{name}" theme="simple"/>
</td>
<td>
<s:textfield name="beanList(%{bean.rollnumber}).location" value="%{location}" theme="simple"/>
</td>
</tr>
</s:iterator>
Refer : http://struts.apache.org/release/2.0.x/docs/type-conversion.html