• 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

Retrieving Form Updates

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having problems with form updates. I am calling an action (getawardmasaction) to populate the form with current data and then I am attempting to read what has been updated with the next action (DeleteAwards?Method=DeleteAward). The form bean never seems to actually be updated by the new input though. When I print the form's data I am getting the original data that was set to the form in the previous action.
I hope this makes sense....I'm a newbie. I'd greatly appreciate any tips!!!
I've pasted code snippets below:
JSP:

Struts-Config:

CrudAwardsAction DeleteAwards java:


[edit: moderator added code tags]
[ October 10, 2003: Message edited by: Junilu Lacar ]
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to be careful about forwarding from Action to another Action. If you change the form fields in the first Action, those changes will be overwritten when the second Action is invoked because the whole process of extracting parameter values from the request and putting them into the form, validating the values, etc. will be done for the second Action.
 
Jennifer Barber
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My problem is that when the original action displays the results those results are needed by the DeleteAwards action.....however, within the DeleteAwards action I cannot access the changes to the form results using the form that is passed to the action. The form passed to the action contains the original results and not the changes. The only way I seem to be able to see our changes is to go through the request and there appears to be no easy way to get the full list back from the request. It appears that I would have to loop through each of the fields that is sent back using the getParameterNames and compare that way.
On a simple search form we have it working to where we can use the form that is passed to the action to get the updated data. However, on this form we cannot seem to get the updates from the form directly.
What is "suggested" way for an action to accessing updates on a list of records??
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. If I understand your problem correctly, it is that Struts is not introspecting the HTML form values into your Java form object. If so, the problem might be straightforward -- in your jsp, the checkbox is populated from a property named "deleteRecord" on "AwardMasView". Now note this snippet from the taglib documentation:

indexed: Valid only inside of logic:iterate tag. If true then name of the html tag will be rendered as "id[34].propertyName". Number in brackets will be generated for every iteration and taken from ancestor logic:iterate tag. [RT Expr]

My emphasis. My understanding is that, because the "id" of the enclosing <logic:iterate> tag is "AwardMasView", Struts will give this checkbox the name "AwardMasView[0].deleteRecord" and so on. For introspection to work, the checkbox should actually be named "awards[0].deleteRecord" because that's the property name on the action form, "awardMasResultsForm".
Try changing your loop variable name. Don't forget to clear the checkbox values in reset().
- Peter
[ October 11, 2003: Message edited by: Peter den Haan ]
 
This is my favorite 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