• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Updating List of Beans on Submit in Struts 1.3.10

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
We noticed he had no friends. So we gave him this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic