My form has a parameter consisting of a grid/table (presented via s:iterator) of data together with other fields represented in my action class as:
public class MyAction extends ActionSupport {
private MyParameter param;
public String execute() { ..... }
// getter and setters
}
Here is MyParameter class:
public class MyParameter {
private List<GridData> gridDataList;
private String subParam1;
private String subParam2;
// getters and setters here
}
Here is GridData:
public class GridData {
private String title;
private String arg1;
// etc... getters and setters...
}
I am able to successfully submit the values of grid data to perform some validation. I am able to add field errors to other parameters by this:
super.addFieldError("param.subParam1", "subParam1 error message");
super.addFieldError("param.subParam2", "subParam2 error message");
What I would like to do is to iterate through my list, and add error messages to each of the elements in the list. I tried doing the following but it does not seem to work:
for(int intRow=0; intRow < param.griDataList.size(); intRow++) {
super.addFieldError("param.gridDataList[" + intRow + "].arg1", "error message");
}
I then rendered the field errors in JSP using iterator. I know that the above is possible because when I check the generated HTML after processing, the field show the 'cssErrorClass' that I have set in JSP. That is:
<s:textfield
name="param.gridDataList[%{#outerStat}].data"
cssClass="grid_text_field"
cssErrorClass="error_field" maxlength="7"/>
Where outerStat is the status (counter) set in the iterator. This generates:
<input
type="text"
name="param.gridDataList[0].data"
class="grid_text_field error_field"
maxlength="7"/>
But no field error message is generated in the tag:
<s:fielderror fieldName="param.gridDataList[%{#outerStat}].data"/>
Can anyone kindly point out what I have done wrong here?