Re: ActionForm - redirect to custom JSP after validation failed

2004-01-13 Thread Mark Lowe
You could forward (not redirect) to a generic failure page if there are 
errors present. I confess i haven;t done this but it could be what you 
want, even forward to a global forward defined in struts config, so you 
can reuse you error page for other stuff.



On 13 Jan 2004, at 16:27, Christian Schlaefcke wrote:

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]


RE: ActionForm - redirect to custom JSP after validation failed

2004-01-13 Thread Richard Hightower
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]



Re: ActionForm - redirect to custom JSP after validation failed

2004-01-13 Thread Kris Schneider
If I understand what you're asking, try setting validate=false in your action
mapping so that validation is deferred to your action. Otherwise, Struts will
perform validation automatically and, as you've noticed, never invoke your
action if there are errors.

Another option would be to keep validate=true (that's actually it's default
value), but change input=/failure.jsp (or wherever else you want to forward
upon validation errors - it can even be another action).

Quoting Christian Schlaefcke [EMAIL PROTECTED]:

 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

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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



RE: ActionForm - redirect to custom JSP after validation failed

2004-01-13 Thread Dhaliwal, Pritpal (HQP)
I generally like to stay away from using login.jsp AND a failure.jsp. Mainly
because its two different pages to maintain, when they look very similar.

So use just login.jsp for both just simple login, and failure.

I would suggest that in your DisplayLoginAction or similar, set a request
attribute like isDisplayLogin that tells you that it is not a failure. If
after validation failture you are being forwarded to login.jsp ,
isDisplayLogin will not be set. Now you can render the jsp with your failure
stuff. 

I am not a Struts expert, but my feeling is that you SHOULD be checking if
user has entered login and password, but you SHOULD NOT be checking if that
combination is right in the FormBean. That SHOULD be done in the Action, so
you can decide what to do next..

My authentication filter is not implemented using struts, so I don't use the
above scenario myself, yet.

My 2 cents..

Pritpal Dhaliwal


-Original Message-
From: Richard Hightower [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 13, 2004 9:20 AM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: RE: ActionForm - redirect to custom JSP after validation failed


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]



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



RE: ActionForm - redirect to custom JSP after validation failed

2004-01-13 Thread Christian Schlaefcke
Thank you for your advices! That helped improving my understanding of
struts alot! At first glance I like the aproach with validate=false and
calling the validate method myself in the LoginAction class, so I have the
control when to validate.

Regards,

Chris

 I generally like to stay away from using login.jsp AND a failure.jsp.
 Mainly
 because its two different pages to maintain, when they look very similar.

 So use just login.jsp for both just simple login, and failure.

 I would suggest that in your DisplayLoginAction or similar, set a request
 attribute like isDisplayLogin that tells you that it is not a failure. If
 after validation failture you are being forwarded to login.jsp ,
 isDisplayLogin will not be set. Now you can render the jsp with your
 failure
 stuff.

 I am not a Struts expert, but my feeling is that you SHOULD be checking if
 user has entered login and password, but you SHOULD NOT be checking if
 that
 combination is right in the FormBean. That SHOULD be done in the Action,
 so
 you can decide what to do next..

 My authentication filter is not implemented using struts, so I don't use
 the
 above scenario myself, yet.

 My 2 cents..

 Pritpal Dhaliwal


 -Original Message-
 From: Richard Hightower [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, January 13, 2004 9:20 AM
 To: Struts Users Mailing List; [EMAIL PROTECTED]
 Subject: RE: ActionForm - redirect to custom JSP after validation failed


 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]



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