File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Use form bean in more than one action method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Use form bean in more than one action method" Watch "Use form bean in more than one action method" New topic
Author

Use form bean in more than one action method

rames tirrupur
Greenhorn

Joined: Jul 25, 2006
Posts: 13
Hi All,

Is it possible to use one form bean in more than one action method.

If so.How?

Thanks,
ramesh
azhar bharat
Ranch Hand

Joined: Jul 17, 2006
Posts: 87
Yes,
in struts config file, give scope attribute as session for formbean.


The formbean will be stored in the session with name as specified in your form-bean tag in struts config file
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Even if you don't put the ActionForm in session scope, you can still use the same ActionForm for multiple actions. All you have to do is specify the same name attribute. For an action, it's not the name that must be unique, but the path. Here's an example:



If you don't put the ActionForm bean in session scope, then Struts will create a new instance with each request, so if you want to share data between actionOne, actionTwo, and actionThree, then azhar is right... You would have to put the bean in session scope.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use form bean in more than one action method