This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes struts-reset() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts-reset() method" Watch "struts-reset() method" New topic
Author

struts-reset() method

Gangireddy Danam
Ranch Hand

Joined: Aug 08, 2012
Posts: 32

Tell me about reset() method in functionality with one example ?
if i had included reset () having session scope for FormBean what happens ? with request scope what happens ()?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Moving to a more appropriate forum.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8935
    
    9

reset() can be used to reset bean properties to their default state, as needed. This method is called before the properties are repopulated by the controller.

The default implementation does nothing. In practice, the only properties that need to be reset are those which represent checkboxes on a session-scoped form. Otherwise, properties can be given initial values where the field is declared.

If the form is stored in session-scope so that values can be collected over multiple requests (a "wizard"), you must be very careful of which properties, if any, are reset. As mentioned, session-scope checkboxes must be reset to false for any page where this property is set. This is because the client does not submit a checkbox value when it is clear (false). If a session-scoped checkbox is not proactively reset, it can never be set to false.

This method is not the appropriate place to initialize form value for an "update" type page (this should be done in a setup Action). You mainly need to worry about setting checkbox values to false; most of the time you can leave this method unimplemented.


Struts Javadoc


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Gangireddy Danam
Ranch Hand

Joined: Aug 08, 2012
Posts: 32

@Joe Ess
Thankyou..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts-reset() method