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

reset method

vidya mahavadi
Ranch Hand

Joined: Nov 24, 2004
Posts: 34
Hi,

I have a situation where the reset method is getting called after setting the form properties and before populating them on the screen.

When does the reset method in action form gets called.. Is it before setting the action form properties or after setting the action form properties?

Please can anyone clarify..
dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
The reset() method gets called before the setters are called.
vidya mahavadi
Ranch Hand

Joined: Nov 24, 2004
Posts: 34
Thanks for the response!

in the application I have I have a big list of notifications which I get from database and post it to the jsp as 10 notifications per page. In my action form I implemented reset method to reset the boolean properties of the notifications which are represented as checkboxed on the screen.

The reset method is called twice!!! It is called before setting the data to the action form and after setting it. Hence I never have the updated proeprties on my screen.

I wonder if anyone had this kind of situation.. Please help me!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
For a single Action, Struts will only call reset() once just before it calls the setters.

Are you doing "action chaining"? If so, that may cause it to get executed twice, because you're actually calling two different actions.

For example, suppose you have an "initPage" and a "processPage" action, both of which are defined to use the "myForm" ActionForm. If, in the Action class for processPage you then forward to "initPage.do", the reset method for myForm will execute twice: Once before calling the "processPage" action, and once before calling the "initPage" action.

You can solve this problem by not using action chaining.

I'm not sure if this is the problem you're experiencing or not, but it's one possibility.


Merrill
Consultant, Sima Solutions
vidya mahavadi
Ranch Hand

Joined: Nov 24, 2004
Posts: 34
Yah.. I was using single action form for multiple actions (one forwarding to another). That was the culprit and thanks to you for helping me fix it.

Regards,
Vidya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reset method