New struts actionform ,creation and reset() method
This is an issue that i faced while using struts.
Struts has ActionForm classes, and they have a defined scope in the mapping file. Scope could be page, request or session.
Now , there are two issues.
1) Do not rely on the constructor of the from bean
The reason is that struts is implemented such that it first checks in the appropriate scope for the form bean, and if it finds the bean it uses the same bean after calling reset(). This means that there could be times when your form bean constructor is not even called!!!
http://struts.apache.org/userGuide/building_model.html#actionform
2) Be aware of how the reset() method works.
If you have form beans stored in session scope make sure that you implement the reset() method. The reason is the that reset() method is called when the continer takes the bean from that scope and uses it after it calls the reset() method to clean up the bean. The default implementation is to do nothing in the Actionform superclass's reset() method.
Also since you cannot thus rely on the constructor, you might as well have a reset() method to initialize code.
http://struts.apache.org/userGuide/building_controller.html#action_form_classes
0 Comments:
Post a Comment
<< Home