This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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.
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
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.
<a href="http://husted.com/struts/book.html" target="_blank" rel="nofollow">Struts in Action</a>