Hi,

I am working on a project that has a similar requirement to
dynamically construct and validate forms at runtime based on
information received from a back-end server. We are building a
front-end to a document management system.

I have spent a little bit of time researching into how Struts can be
used to support this requirement. I quickly came to the same
conclusion as you, that since Struts is driven from configuration
files, it is not truly dynamic.

The current approach I think will work is to use the underlying
Commons Validator and BeanUtils packages directly. A brief
investigation into the Validator shows that it is possible to supply
validation rules without requiring a static file. Equally I am sure
that the BeanUtils can be used to construct a dynamic form (that is
the point of it after all :-).

I intend to model the code in Struts to create an action that will
populate a dynamic bean and validate it.

Another big challenge is how to generate the HTML page. Since the form
is truly dynamic, it is not possible to use a simple JSP. I am not
sure what is the best approach to take here - especially as I would
like to the Struts tag libraries for form population (and hopefully
JavaScript validation). Some thoughts are:

- Write a JSP that loops over the fields to display, and have a
  massive case statement for each support type

- Use straight Java code and generate the HTML directly

- Write a custom tag library (variation on previous idea)


If any body out there has some real life experience out there with
these problems, it would be great to hear from you.

Regards,
Oliver

> -----Original Message-----
> From: Alex Birch [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 16 August 2002 01:08
> To: [EMAIL PROTECTED]
> Subject: generating dynamic forms from XML at run-time (not
> initialisation time)
> 
> 
> Hi,
> 
> I'm having difficulty working out how to do the
> following using struts:
> 
> 3 separate pages:
> 
> 1. question.jsp... asks how many text boxes on the  
> next page and what the form name of each text box
> should be
> 
> 2. dynamicForm.jsp... displays a form with the number
> of text boxes specified in question.jsp - each named
> accordingly
> 
> 3. results.jsp... concatenates all the text box
> entries into a single string and displays it as simple
> text.
> 
> Is that possible? I can't find a way to do it (without
> some heavy rewriting). I've seen examples using
> indexed properties but I'd like to emulate the way
> DynaActionForms does it from the struts-config.xml.
> The problem is that the FormBeanConfigs are frozen
> (with freeze()) at init stage of the ActionServlet.
> 
> I want to generate a particular form at run-time from
> an xml file (similar to the form-beans section of
> struts-config.xml 1.1b2) which is also generated at
> run time.
> 
> I'd like to load the XML file inside an Action, edit
> the FormBeanConfig for the correct mapping ActionForm
> instance and forward to the dynamic form displaying
> page with an appropriate bean.
> 
> Can anybody tell me if this is possible (and how) with
> struts?
> 
> thanks
> 
> Alex
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 

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

Reply via email to