• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

iterating over a user defined class object using logic iterate

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a list of user defined objects to iterate over using logic:iterate. The values of the object are being displayed in a text box so that the users can update the values. After th user updates the value in the front end,I am not able to retrieve the corresponding line item modified.

Assuming there are 5 line items being displayed using logic:iterate over a list (list contains objects of user defined class), if the user needs to update a value in thatz present in the 3rd line item, using an id field(property in the user defined class), iam able to determine the row. but in the action class when the form bean's object is accessed the 1sr line item's values are retrieved rather than the 3rd.

Kindly help.

Logic - iterate code
<logic:iterate id="custConId" name="WSREditFormBean" property = "custConcerns" type="bean.ConcernsVO">
...
...
<bean:define id= "conId" name="custConId" property="concernId" />
...
<html:text indexed="true" name="custConId" property="concernDesc" styleClass="tbclrwhite" />
...
...
</logic:iterate>
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you may want to have a unique id associated with each line item (another property inside the user-defined object) rather than using the index of the list. especially when line items can be removed or added that can throw the index out of whack going from JSP into form then to your action. -/a
 
san geetha
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do have an unique id associated with each line item... (ie) concernId
My problem is if i want to update a value in the 3rd LItem, then iam not able to get the handle to the altered LItem. In the action class, i have the formbean's object... but it always contains the value of the first LItem.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i see what the problem is. you must set your value objects values into the ActionForm that is mapped that that action, not putting it into a "formbean". (unless your WSREditFormBean IS the name of the form you mapped that action to, in which case i misunderstood).

you then need to access the line items by iterating through the "MyForm.map.myItems". in your case, you'll need to do the following:

1. form-bean definition must contain
<form-bean name="ConcernForm".../>
<form-property name="custConcerns" type="bean.ConcernVO[]"/>

2. your action execute method then populates the properties using form.set("custConcerns",ConcernsVO[])

3. in your logic:iterate, you need to access the form by something like...
<logic:iterate id="custConId" name="ConcernForm.map.custConcerns" property = "custConcerns" type="bean.ConcernsVO">
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic