• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating List of Beans on Submit in Struts 1.3.10

 
Dan Idoux
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone help me with a problem? I have a form with a list of text boxes that I want to be able to update on submit.

public class PrjPerformanceActionForm extends ActionForm {


private List measures;

}

List is an ArrayList of a Nested object with getters and setters that is populated from a database and displayed on the form. The problem is on submit. Struts is not calling any of my setter methods. It should be calling setFieldAsString(String s).

public class ProjectPerformance implements Serializable {

private ProjectPerformanceMeasures projected;
private ProjectPerformanceMeasures verified;

}

public class ProjectPerformanceMeasures implements Serializable {


private long field;


public long getField() {
return field;
}


public String getFieldAsString() {
return GLOBAL.getLongAsNumber(field);
}

public void setFieldAsString(String txtField) {
field = GLOBAL.getValueAsLong(StringHandler.stripSpecialChars(
txtField));
}

JSP
<nested:iterate id="prjPerfMeas" name="<%=formName%>" property="measures">
<html:text name="prjPerfMeas" property="projected.fieldAsString" maxlength="15" size="15">
</html:text> 
</td>
<td align=center>
<html:text name="prjPerfMeas" property="verified.fieldAsString" maxlength="15" size="15">
</html:text>
</td>
...
</nested:iterate>



Any help would be appreciated.



 
Dan Idoux
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the problem. The name has to match the id and then it works.

<nested:iterate id="measures" name="<%=formName%>" type="classname" property="measures" indexId="idx">

<nested:iterate id="measures" name="<%=formName%>" property="measures">
<html:text indexed="true" name="measures" property="projected.fieldAsString" maxlength="15" size="15">
</html:text>
</td>
<td align=center>
<html:text indexed="true" name="measures" property="verified.fieldAsString" maxlength="15" size="15">
</html:text>
</td>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic