This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi folks I have been developing an appliction in using struts configuration of action and form beans. Now i m using a action class and calling a form bean from it so that using request i can get data which i can display in the JSP. Now i have generated other action class but want to fetch the same data for the display, my question is that can i map a single form with two different action classes? And also after doing so will my first functionality be affected as i will be accessing same form from different classes during same session.
Thanks in advance for giving me some tip or so in this regard.
You can use the same form bean by any number of actions. This is quite commonly done. Many Struts developers follow a pattern of creating at least 2 actions for every panel: An init action and a process action, both of which use the same form bean.
If you have your action configured to use session scope (the default) then yes there can be side effects of using the same form in different actions. Struts will store your populated form in session and all actions will use this same instance. In this case you have to think about how you want to implement the reset method on your form
As a rule I configure my actions to use request scope. In that case Struts instantiates a new instance of your form with each new request so data is not retained from previous actions. I am a little fuzzy on best practices regarding the reset method since I generally do not have to worry about implementing that method.