Checking for a submit control in the request is very clever. Another approach would be to setup an alternate ActionMapping with validate=false. This could either lead to a separate Action that prepopulated the form, or a task in the same Action, queued by a hidden property or the parameter property from the mappig. (I tend to do the latter.)
Even when a form does not need to be prepopulated, I would queuing it through a mapping, even it just forwards to a JSP. <action path="/Input" forward="/pages/Input.jsp"> </action> This gives you the opportunity to interpose an action later, should one be needed, and keeps the entry points documented in the struts-config. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel +1 716 737-3463 -- http://www.husted.com/struts/ Dave Remy wrote: > > I am doing this (doing the GET to the action class to prepopulate the form) > and it works well but there was one interesting thing that happened > (assuming I have everything set up right). The validate() method in the > related form bean was called as well. Consequently, I am having to start > all of my validate() methods with: > if (request.getParamater("submit") == null) > so that I don't do edit checking on a GET ... No big deal, but am I missing > something? > > -----Original Message----- > From: Ted Husted [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, October 09, 2001 9:01 PM > To: [EMAIL PROTECTED] > Subject: Re: PrePopulating a form > > The trick is to route control through an Action before display any JSP. > The Action does all the real work, like populating the form. The JSP > just displays the result. > > http://jakarta.apache.org/struts/userGuide/building_controller.html > > -- Ted Husted, Husted dot Com, Fairport NY USA. > -- Custom Software ~ Technical Services. > -- Tel +1 716 737-3463 > -- http://www.husted.com/struts/ > > Minh Tran wrote: > > > > Could somebody let me know what the correct design pattern under struts is > > for prepopulating a form with data.. let say.. for example after someone > > logs on.. so a form is automattically filled out with their appropriate > data > > for certain fields.. while some fields still need to be filled out.. I've > > got the validation and error handling part down.. > > > > Of course the obvious way to do this.. to my limited knowledge of struts > is > > to some how create the form bean and populate it before is is displayed > > through the JSP... which I think will automatically retreive whatever data > > that's in the form bean.. but i'm still not sure how to make struts creat > > the form bean before the form gets display.. it seems that the form beans > > gets created after the form is submitted so that it can be validated.. > > > > Thanks, > > Minh Tran