Michael Jouravlev wrote the following on 7/6/2005 1:11 AM:
On 7/5/05, Rick Reumann <[EMAIL PROTECTED]> wrote:

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.


Any particular reason for that? Also, if default values are set in
reset(), they will be overwritten by request values if there are any.

Right. That's what you *want* to happen - otherwise what would be the point of reset if it never let the user's input overwrite the form's default values? Reset() is called first by struts *then* the form gets populated with any request parameters that match the form properties.

Usually, this is the preferred scenario. If values are set right
before rendering a page, then request values will be overwritten by
default values.

NO this does not happen when you leave an Action and forward to a page. It only happens on "submit." Maybe you are confusing 'default' values that the form has with 'pre-poulated' values. A form that is used to edit user information, like the original poster mentioned he wanted, are 'pre-population' values - those you would never want to set in a reset (or even worse a validate) method. Are you suggesting it's a good idea to call business logic (DAOs etc) in order to populate a form bean with information such as an "Employee name" or "Address"? Hopefully it's just late and I'm misunderstaning you and you are not saying this:) If by some chance you are, PLEASE do not advise the newbies to do this. This totally defeats the pupose of what ActionForms should be used for and will create all kinds of maintenance headaches, never mind the fact that it's really bad design.

Typically for an "edit" scenario that the user mentioned, you'd click on a link with a userID, go to your Action, look up the UserObject from backend based on userID, populate your ActionForm with the user information, forward to the page to now alow the information to be edited and submitted.

--
Rick

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

Reply via email to