Submitting changes made to Collection/ArrayList

Discussions

Web tier: servlets, JSP, Web frameworks: Submitting changes made to Collection/ArrayList

  1. Submitting changes made to Collection/ArrayList (8 messages)

    Hello, I am trying to pick up the changes made to a collection on a submitted form. The collection created looks like the following:

    <logic:iterate id="secGrp" name="selRptSpec" property="rptSpecAsgn" indexId="keyValue" >
    <tr>
    <td><html:checkbox indexed="true" name="secGrp" property="checked" />
    </td>
    <td>
    <bean:write name="secGrp" property="displayVal" />
    </td>
    <td><html:text indexed="true" name="secGrp" property="description" size="55" maxlength="100" />
    </td>
    <td><html:text indexed="true" name="secGrp" property="appValue" size="3" maxlength="3" />
    </td>
    </tr>
    </logic:iterate>

    "rptSpecAsgn" is an ArrayList of assignment objects. The assignment class has getters and setters for each of the member variables. In my action form I have code for reseting the collection as well as the getter and setter methods.

    All standalone fields on the form are submitted and mapped to thier corresponding variables in the actionForm class with the exception of the rptSpecAsgn collection. I can set the values for each item in the collection and they are displayed correctly in the JSP, but when I submit the form the collection returns empty.

    I am not sure what I am doing wrong here, but I have aged 10 fold getting this to work. Any assistance would be greatly appreciated.

    Thanks,
    Shawn

    Threaded Messages (8)

  2. reset[ Go to top ]

    I guess if you are reseting collectionin the reset method then it is being called after the form submit...This will happen if you are trying to call soem other method in the same action on submit.

    I had similar problem to overcoem this I had to create my own reset method which i call from action only when needed.

    Hope this helps
    Ash
  3. reset[ Go to top ]

    Thanks for the quick response. I removed any code associated with the collection from the reset method and still no luck. ???
  4. hidden[ Go to top ]

    Try to create a hidden property for this collectionin the form and see if it submits.

    Ash
  5. hidden[ Go to top ]

    I am not sure what you mean. I tried to create

    <html:hidden property="rptSpecAsgn" />

    and when I accessed the page I recieved the following exception:

    javax.servlet.ServletException: BeanUtils.populate
    at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
    ...
    ...

    java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    ???
  6. form[ Go to top ]

    Hi,

    Not sue why you have that exception.It should have worked if you have commented reset method lines and have html:form tag properly embedding your required feilds within it on the jsp...If you won't mind you post your jsp here.
  7. Same problem[ Go to top ]

    I am facing the same problem. Did you find any solution for this????
  8. Indexed properties[ Go to top ]

    Solution for this problem is clearly defined at
    http://www.developer.com/java/ejb/article.php/2233591

    go and check it. May contact me at jpe123in at yahoo dot com for clarifications.
    Regards.
    jp
  9. j2sdk1.4 doesnt handle ArrayList[ Go to top ]

    Not sure what the difference is yet but i ran into this problem today when upgrading to j2sdk1.4 from 1.3. After reading another forum somebody suggested that a difference in reflection API between 1.3 and 1.4 is causing this. changing the ArrayList in the form to be an Object[] fixed the issue.