• 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 ValueObjects in Struts

 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
As per the framework the ActionForm is created by the RequestProcessor once it initializes and gathers mapping information from struts-config.xml.The ActionForm is created for every request and it is cached and the properties are reset for the next request.Now if there is a Java Bean with ten public fields and corresponding accessor methods, now if out of these if next request consists of four fields which are part of the previous request, can the same Form object be used...in short is it possible to do lazy loading of the formobjects and using it.
Rishi Singh
SCJP,SCWCD
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lazy loading? What exactly do you mean?
The formbean can be stored in the request or in the session, which you configure yourself. If you put it in the session, the old formbean with its values will still be there when the new request comes in, and so the new request will use the old formbean.
 
Author
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can specify whether an ActionForm is placed in request or session scope. If you place it in session scope, you can just fill up the form a request at a time. If there is a corresponding parameter in the request, the property is populated. Otherwise it is ignored.
If you choose to use request scope, then each form must carry the properties forward using hidden fields.
Generally, I recommend using coarse-grained ActionForms with as many properties as you need for the application (or a group of related forms in a very large applications). This avoids having to maintain the same properties in multiple classes.
If you are using your own validations, you can subclass the base ActionForm and provide a validate for each distinct set of data.
If you are using the Struts validator, you can just define a formbean element for each distinct validation. The Validator doesn't look at the ActionForm class, but the form-bean name.
HTH, Ted.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic