First, the behavior experiencing is as designed. I suggest getting a good
book on Struts geared for Struts novices like Professional Struts published
by Wrox (written by James Goodwill and me).

You can turn validation off in the action mapping (action element in the
struts config file) by setting the validate attribute to false (the default
is true).

That said....

Here is what I would do (and have done in a similar situation).

Turn validation off by setting validate=false on the action mapping:

<action path="/foo" name="loginForm" validate="false"
type="buy.my.book.FooAction">

        <forward name="failure" ...
</action>


Have the action's execute method calll the validation method of the
ActionForm, then forward to anywhere you would like.

ActionErrors errors = form.validate();

//if errors not empty forward to failure
return mapping.findForward("failure");


Rick Hightower
Developer

Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm

Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring

-----Original Message-----
From: Christian Schlaefcke [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 13, 2004 9:27 AM
To: [EMAIL PROTECTED]
Subject: ActionForm - redirect to custom JSP after validation failed


Hi Folks,

I have a simple login.jsp that I want to validate. So I have a Class
"LoginForm" with a "validate" method, that fills up the ActionErrors with
the errors that might occur (missing username/password, wrong
username/password). Later the execute method of the corresponding Action
class "LoginAction" checks those ActionErrors. If not empty I try to
return a forward to "failure.jsp".

The problem I have is that before my LoginAction could execute my custom
forward the RequestProcessor of Struts tells in the logs, that validation
has failed and request will be forwarded to /login.jsp (which is of course
the input item of this action in struts-config.xml). When a validation
error occurs my LoginAction class is never called.

I searched the archive of this list already but couldnīt get through the
solutions I found there. I still donīt understand why this is happening
and what I can do to redirect to a custom failure.jsp.

Could someone please explain in newbie-style ;-) ?

Thanks & Regards!

Chris

---------------------------------------------------------------------
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]

Reply via email to