• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use form bean in more than one action method

 
rames tirrupur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic