Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retaining and clearing out form bean values

 
Aravind Ramanujam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implement an dispatch action with two actions new and edit in your case and write the code correspondingly.
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic