This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Retaining and clearing out form bean values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Retaining and clearing out form bean values" Watch "Retaining and clearing out form bean values" New topic

Retaining and clearing out form bean values

Aravind Ramanujam

Joined: Dec 14, 2004
Posts: 16
I'm implementing a functionality where I've two navigation paths.

One, the user may wish to start over and key in new data.

Secondly, the user might need to edit the existing criteria.

In the action mapping, i've defined the form bean scope as session. This helps if the user wants to edit the criteria. But when the user wants to start over, still the old values are retained. How do i make the form bean reset when the user starts over? The values should be retained when he wants to edit.

Any ideas/suggestions would be deeply appreciated...
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Implement an dispatch action with two actions new and edit in your case and write the code correspondingly.
Vicky Mohan
Ranch Hand

Joined: Oct 14, 2004
Posts: 130
well, when you want to startover, call the reset() in the ActionForm so that all for variables are reset to the default value.

Of course, in the reset(), you need to have implementation to reset all the values ...
[ August 22, 2005: Message edited by: Mohen Vijay ]
Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
You don't even need to write 2 actions, depending on the behavior selected say 2 links calling same action.
Depending on the parameter sent you populate the form or not. and call the jsp.
I agree. Here's the link:
subject: Retaining and clearing out form bean values
It's not a secret anymore!