On 2/7/06, Tom Ansley <[EMAIL PROTECTED]> wrote:
> I guess the big thing I do not understand here is why validator is being
> called when the form has not even had time to initialize.
>
> In my application I rely on the action.execute() method being the first to
> be called because it allows me to prepopulate the form associated with the
> action.  This makes good sense.  Then, the jsp page is created.  Then, when
> the reply comes back from the user, that is when the validation should
> occur.
>
> Is this assumption about the action.execute() method being the first thing
> called a BIG mistake?  What happens if the form needs to retrieve a number
> of lists which are to be displayed in the JSP page?  I do this retrieval in
> the action.execute and place the lists in the form.  Should I be doing it
> somewhere else?
>
> Thanks so much to all for their previous thoughts by the way.

Do not use automatic validation, it screws up action lifecycle.
Anyway, the call sequence is:

* ActionForm.reset
* populate ActionForm from request
* ActionForm.validate if "validate"==true
  ** if ActionForm.validate returns non-null object, Struts skips
     action class altogether, and selects path corresponding to
"input" property.
  ** If validate() returns null, then execute() is called on action class.

See? Turn autovalidation off and throw out "input" attribute,
everything will be much more straightforward. Also, if you have not
got it yet, "input" does not mean "this is input page where I start
off filling out my form", it means "this is the page to show in case
of error".

About preparing form for display: if you can ensure that your input is
sent via HTML FORM, then you can choose POST method only for form
submission, and then differentiate by request type: POST means
postback, GET means initial render.

Michael J.

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

Reply via email to