• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reusability of the form

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Prams
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

- Brent
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic