My way to solve this kind of problem:
(1) Use a DTO class as the data modal for columns of each row.
Every column is represented by one property of the DTO class.
For example:
public class Info {
private boolean use;
private String name;
private int id;
// getter and setter is omitted
}
(2) In the action class, use a property to represent the rows, and the
data type of this property is List<DTO> .
For example:
private List<Info> infoList = new ArrayList<Info>();
// getter and setter is omitted
// initialization code is omitted
(3) In JSP, use a <interator> tag on the List, to display rows for
each DTO instance:
For example:
<s:iterator value="infoList" status="rowStatus">
ID: <s:textfield name="infoList[%{#rowStatus.index}].id" />
Name: <s:textfield name="infoList[%{#rowStatus.index}].name" />
<s:checkbox label="Use"
name="infoList[%{#rowStatus.index}].use"/>
<br/>
</s:iterator>
The data initialized in action class will be display in your page, and
the data inputted by user will be applied to the List<DTO> property.
I think this is a better design, because the data modal is more
compliant with OO principles.
Hope this helps.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]