aspose file tools*
The moose likes Struts and the fly likes Retrieving Form Updates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Retrieving Form Updates" Watch "Retrieving Form Updates" New topic
Author

Retrieving Form Updates

Jennifer Barber
Greenhorn

Joined: Oct 10, 2003
Posts: 3
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 ]
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4456
    
    6

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.


Junilu - [How to Ask Questions] [How to Answer Questions]
Jennifer Barber
Greenhorn

Joined: Oct 10, 2003
Posts: 3
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??
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving Form Updates