Dynamic Form Elements
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Brandon_Goodin
Posted On:   Thursday, November 8, 2001 01:11 PM

I posted this earlier but I received no comments on specific current solutions that will address this problem. I was also wondering if the nightly build has the following ability within it. Let me give an idea of what I am trying to accomplish and then see if you can feedback. Using struts (obviously) I am creating a reusable contact form. It is configured through an xml-config file that defines where the contact form goes and the smtp server it is to use, etc.. I want to set it up so that it does not have to be recompiled upon alternate use. This is one part of a set of components that make it easy for web designers to add functionality to websites they are building using the struts framework (whether they know it or    More>>


I posted this earlier but I received no comments on specific current solutions that will address this problem. I was also wondering if the nightly build has the following ability within it.


Let me give an idea of what I am trying to accomplish and then see if you can feedback.


Using struts (obviously) I am creating a reusable contact form. It is configured through an xml-config file that defines where the contact form goes and the smtp server it is to use, etc.. I want to set it up so that it does not have to be recompiled upon alternate use. This is one part of a set of components that make it easy for web designers to add functionality to websites they are building using the struts framework (whether they know it or not). i.e. most web designers to not have ide for compiling java classes. So, with those design goals in mind let me share with you my issue.


The contact form by default captures the Name, Address, City, State, Phone Number, and any other basic contact form info needed. It has an ActionForm bean that captures the input of these predefined items and the data is then passed on to the Action and sent as an email to the recipient. My hangup
is... I need to allow the flexibility of adding form elements to the form that are not defined in the ActionForm bean. I would also need to be able to pass the values back to the form in the event that a validation error occurs with the form. With the model the way it is I would have to specifically
define the setters and getters in the ActionForm so that the Action could retrive the values of each form element and use them or route them back to the input form for errors or to another Action.


Is there a way to have a generic getter/setter that can capture any non defined data? For example say a company cleans linen and they want to add a form element that asks for the type of detergent the contactee prefers. The added form element is called "preferredDetergent" yet it is not specifically
defined in my ActionForm bean. First, how would I avoid getting an error that says preferredDetergent is not defined in xxxForm? Next, how would I then capture that value in the ActionForm for use in error checking and/or usage in the Action class?


Brandon Goodin

Phase Communications

P (406)862-2245

F (406)862-0354

http://www.phase.ws
   <<Less

Re: Dynamic Form Elements

Posted By:   Ted_Husted  
Posted On:   Friday, November 9, 2001 07:37 AM

The ActionForms extend the html:form tags so that they can be populated, and repopulated, from the request.


The ActionForm properties and the tags are tightly coupled, and neither are designed to be used dynamically.


Of course, not every property has to be populated. So there could be the old trick of adding several "UserDefined" properties to form. In the JSP, the properties might be labled user1, user2, et cetera, but the external user labels could be anything at all.


Using the validator form, error checking can be performed by updating the validate.xml and Application resources and restarting the application.


In the Action itself, you would need to add some type of handler to check if the user defined fields were not null. To label them in your email message, you could do some type of "reverse lookup" on the application resources, to get the field labels from the validation messages.


HTH - Ted

About | Sitemap | Contact