Tony Dahbura wrote the following on 7/5/2005 7:36 PM:

For instance I have a form that lets user edit their profile and I want to pre-populate with their name and phone number etc...Should I do all this in the form's actionForm reset method or where?

No! Do not do this in the form's reset or validate method.

You do this kind of "set up" in an Action class BEFORE you end up going to the page.

I like to use a DispatchAction vs a regular Action class for keeping related operations in one class but if you are going to use a single Action you would first go to a "SetupAction" or if using a dispatch Action you'll have a method "setUp(..)" in there you would do...


setUp(..) {
   YourActionForm yourForm = (YourActionForm)form;
   EmployeeBean employee = SomeObjectOrDAO.getEmployee(..);
   //now populate yourForm with employee info
   //you could do yourForm.setFirstName( employee.getFirstName() );
   //but it's MUCH easier using PropertyUtils (download from commons)..
   PropertyUtils.copyProperties( yourForm, employee);
   return (mapping.findForward("continue"));
}

Use the reset method only for doing things like making sure some boolean fields are set to false. I highly recommend you DO NOT use the reset for 'business type' logic. Having a few default things set there is fine, but for stuff like you are suggesting, you do that in an Action class or DispatchAction method BEFORE you forward to the page.

--
Rick

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

Reply via email to