You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mulligan, Scott H" <sc...@eds.com> on 2005/11/17 22:32:22 UTC
Updating ActionForm from indexed properties
My actionForm has an ArrayList of objects that I display in my JSP for update using indexed properties (see below JSP code):
<logic:iterate id="objectVO" name="FormConfig" property="objectCollection" type="com.xxx.MyType">
<html:text name="objectVO" property="stringProperty" indexed="true" />
<html:text name="objectVO" property="intProperty" indexed="true" />
</logic:iterate>
My Action Form looks like this:
public ArrayList getObjectCollection() {return objectCollection;}
public void setObjectCollection(ArrayList p_ObjectCollection) {objectCollection= p_ObjectCollection;}
public void setObjectVO(int index, MyType p_object) {objectCollection.set(index, p_object);}
public MyType getObjectVO(int i) {return (MyType) objectCollection.get(i);}
The object class has a String property and an int property.
The information gets displayed properly and updated properly when valid data is entered. However, if the user enters a non-numeric value for the intProperty field, the int property in the object in the ArrayList in my actionForm gets set to 0. Is there a way to trap this situation or to a way to avoid this from happening?
Thanks for your help