This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Use form bean in more than one action method

 
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
 
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
 
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.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic