At 5:29 PM +0800 1/29/05, Eric Chow wrote:
How can I not use the struts-config.xml but I can use my own config to
generate a HTML form and use a standard validator to validate the form
data ??

When Struts goes to get you a form bean (based on the "name" attribute of an <action> mapping, it goes to the current ModuleConfig object and calls "findFormBeanConfig(String name)".


You can call "addFormBeanConfig" on a ModuleConfig object any time before the Servlet init process is done; probably the best place to do this is in a PlugIn class, whose init method gets handed the ModuleConfig. In the example I cited, we looked up "form" information from a database schema representing a survey, and created FormBeanConfig objects based on that data, and added them to the Module's set of available forms. If I recall, the PlugIn was designed to take as config properties the unique ID of the survey config database record and a form bean name; if we had needed more than one per app, I probably would have just set up a series of PlugIns, each with the responsibility of instantiating one FormBeanConfig.

This is not extremely complicated, but at this point if you still have questions, I'd suggest getting a copy of the Struts source code and tracing this through. (In general, I'd suggest this for anyone with the slightest curiosity. It's really not so complicated, and it will give you a much broader idea about how you can make Struts do what you want it to do.)

Joe




On Fri, 28 Jan 2005 10:12:32 -0600, Joe Germuska <[EMAIL PROTECTED]> wrote:
 At 8:03 AM -0700 1/28/05, Wendy Smoak wrote:
 >From: "Eric Chow" <[EMAIL PROTECTED]>
 >
 >>How can I create forms without defining it in the struts-config.xml?
 >>I mean I want o use my own config and generate a HTML form with Struts
 >>action handling.
 >
 >Take a look at LazyDynaBean and LazyValidatorForm.  There's some
 >information on the wiki:
 >http://wiki.apache.org/struts/StrutsCatalogLazyList  section 2.4 .

 A developer on my team developed a system to retrieve survey
 configuration data from a database and present it to users in Struts.
 This involved dynamic form creation and validation.  The gist was
 that a PlugIn, when initialized, used database data to create and
 register DynaForms.  I believe it was a subclass of
 DynaActionValidatorForm which could interact with this same PlugIn to
 do the Survey specific validation (where the rules came from the
 database) while delegating validation for any standard fields (like
 contact info) to normally configured validator XML.

 As Wendy points out, now that there are LazyValidatorForms, this
 would probably be simpler, because you would only need to extend the
 validation method, and could probably skip defining new form classes.

 Joe

 --
 Joe Germuska
 [EMAIL PROTECTED]
 http://blog.germuska.com
 "Narrow minds are weapons made for mass destruction"  -The Ex

 ---------------------------------------------------------------------
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Narrow minds are weapons made for mass destruction" -The Ex


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to