File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Updating List of Beans on Submit in Struts 1.3.10 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Updating List of Beans on Submit in Struts 1.3.10" Watch "Updating List of Beans on Submit in Struts 1.3.10" New topic
Author

Updating List of Beans on Submit in Struts 1.3.10

Dan Idoux
Greenhorn

Joined: Feb 03, 2010
Posts: 2
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

Joined: Feb 03, 2010
Posts: 2
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating List of Beans on Submit in Struts 1.3.10
 
Similar Threads
Multi check boxes error
ArrayList inside an ArrayListVO
struts validation
Nested Tag (in Form of Table ) :: not able to submit masterForm
form bean is not getting updated upon submit in jsp