I think there is a disconnect caused by my course grained answer. Let me explain in further detail.
OBJECTIVE: The objective is to request a URL which returns a .jsp page which is populated with information from the database. The subsequent objective is to return the .jsp page with any invalid data along with prepatory information from the database (such as a drop down list) when Struts detects a validation error. A SOLUTION: Define 2 actions. For this example, I'll call them PopulateFormAction and ProcessFormAction. Define 1 form, call it MonitorForm, which is used by both actions and is in request scope. PopulateFormAction is responsible for preparing data which will be rendered on the .jsp page. For example, let's say page has a drop down list where the options are populated from database. ProcessFormAction is responsible for processing user input after it successfully passes validation. When a user invokes the PopulateFormAction, Struts will look for Monitor form in the request; if not found will create it, and expose it to the PopulateFormAction. Note, here that if Struts will auto-magically populate the form with any request parameters that match the forms data members. The PopulateFormAction then retrieves (delegates to the appropriate business object) the appropriate data needed by the MonitorForm, populates it, and forwards the response to the ActionForward defined in the struts-config file which will be the appropriate .jsp page; let's call it monitor.jsp. The <html:form .../> in monitor.jsp whose action attribute is defined to invoke ProcessFormAction, will "see" that MonitorForm exists in the current request and will render it appropriately. The user fills in the form and submits the request. Struts validation detects an error and looks to the input attribute value of the action mapping for ProcessFormAction to determine how to respond. NOTE: The input attribute value of the action mapping for ProcessFormAction we define as the URL which invokes PopulateFormAction and NOT monitor.jsp Struts, then forwards the request (which still contains the user input but NOT the MonitorForm-because we lost that once the page was rendered), to PopulateFormAction which will then populate the form with any data that exists in the request parameters (which is the invalid user input) and then will repopulate the form with the database data. Whewwww. Sorry to be so long winded, but I wanted to make sure I didn't gloss over anything. This does work, because I use this technique almost exclusively. THE EXCEPTION: Now, the exception to this rule, would be if the data from the database needed to render the page doesn't change from user to user. At this point, you should populate that data in the ServletContext when the application initializes and then it will be there for all users as long as the application lives. On the page, you just reference the appropriate attribute under which the data was persisted. As to how this works with Tiles, I'm unsure, because I haven't worked with them yet...although I look forward to it, because they sound very powerful. HTH, robert > -----Original Message----- > From: Michael Mattox [mailto:[EMAIL PROTECTED] > Sent: Friday, March 14, 2003 6:27 AM > To: Struts Users Mailing List > Subject: RE: How to populate a form with data and then have the > DynaValidatorForm validate it afterwards > > > > Have 2 actions: > > > > -PopulateFormAction > > -ProcessFormAction > > > > When the user clicks to edit the Monitor, invoke, PopulateFormAction. > > When the user submits invalid data (invoke ProcessFormAction), > > the request should forward back to the input defined in the > > struts-config file. All the form data still resides in the request > > and should therefore be rendered again (without hitting the database). > > I don't think this will work. The first action retrieves a > Monitor from the > database and puts it into the request. The JSP will then set the > values for > each of the form components using the Monitor object in the request: > > <html:text property="name" size="20" value="<%=monitor.getName()%>"/> > > The user then submits the form. The Sturts Validator will > validate the form > input. If there is a validation error Struts will redisplay the JSP. But > at this point there won't be a Monitor object in the request. And even if > there was, the JSP should be displaying the values from the Form bean and > not from the Monitor object. To use the From object to populate > the form, I > have to remove the value assignment: > > <html:text property="name" size="20"/> > > But then the question is how do I copy my Monitor object into the Form? I > succeeded in doing this with BeanUtils but when I enable the validation my > app gets stuck in an endless loop and the tiles in my page get > repeated over > and over. I'm trying to track it down but I need to install the Struts > source first. > > Michael > > > > --------------------------------------------------------------------- > 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]

