• 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

Bean declarations in struts

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the advantage of using <form-beans>. Why wouldn't you just add beans to the session object as needed and use EL, JSTL, and standard actions to access the data?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main advantage of using ActionForm beans is that it serves as a Java representation of the data on a page. Struts automatically "binds" the form bean to the page and transparently transfers data to and from the form bean, thereby saving you a lot of code.

When used in conjunction with the html:xxx tags (html:text, html:select, html:radio, etc.) your form elements will be populated automatically by Struts. So, in stead of writing:

you just write

If the "firstName" property of the form bean has a value when the page is rendered, it will be displayed.

Similarly, when the form is submitted, Struts automatically transfers all values submitted with the form to the ActionForm bean without you having to write any code to do so.
 
David Heffington
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see. In addition, I suppose that declaring the bean in the struts-config.xml serves as a centralized reference when multiple developers are working on the same project. Ok, I'll go down the road

Thanks!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic