What kind of form are you using? I'm implementing a validatorform, and I
use the following hack to allow the same action to populate the form
before validation. This code is put in my implementation of the validate
method:
if (request.getMethod().equals("POST")) {
ActionErrors errors = super.validate(mapping, request);
return errors;
} else {
return null;
}
This code only triggers validation when there is a POST in progress.
Hope this helps.
Anders,
On Mon, 31 Mar 2003, Veaceslav Chicu wrote:
> Hi,
>
> I'm intereseted if you found a better solution, because I have this problem
> too
>
> best regards,
> Slavic
>
> ----- Original Message -----
> From: "James Higginbotham" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, March 29, 2003 2:44 AM
> Subject: MVC + Validation tips?
>
>
> Hi,
>
> After searching the archives, I couldn't find an email that described a
> good solution to my question, and Ted's sample chapter on Validation
> didn't touch on it either. I have an action that is called which
> prepares the appropriate data and forwards to a JSP which contains a
> struts form. I have validation turned on now, so the action tries to
> validate and fails when its initially called, thus preventing my data
> from being loaded (it just goes to the input page, itself). My current
> workaround is to do the following:
>
> <action path="/editor"
> type="my.editor.EditorAction"
> name="editor"
> scope="request"
> input="editor.default"
> validate="false">
> <forward name="editor.default"
> path="editor.default"/>
> </action>
>
> <action path="/editorSave"
> type="my.editor.EditorAction"
> name="editor"
> scope="request"
> input="editor.default">
> <forward name="editor.default"
> path="editor.default"/>
> <forward name="editor.save.success"
> path="/viewer.do"/>
> <forward name="editor.cancel"
> path="/viewer.do"/>
> </action>
>
> I then call the /editor.do first, and that renders a JSP that will POST
> to /editorSave.do and validate the form. Is there a better way to handle
> this, or is this the preferred method when honoring MVC and only
> requesting pages via Actions?
>
> Thanks,
> James
>
>
>
>
> ---------------------------------------------------------------------
> 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]