You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Frank W. Zammetti (MLists)" <fz...@omnytex.com> on 2005/02/02 18:38:46 UTC

Extending RequestProcessor to handle validation errors

Hi folks... I'm working on an update of my Struts Web Services project,
and I can't seem to work out how to do something...

What I want to do is have a way to redirect to a given JSP when ActionForm
validation errors occur that will OVERRIDE whatever might be configured in
the action mapping.  In other words... in a normal application, validation
errors occur and we get forwarded back to the input page.  I want to be
able to redirect to a different JSP, REGARDLESS of what the input page is.

I looked at overriding the processValidate() method of RequestProcessor,
but I don't see how that can work... Looking at the source of the original
RP (v1.1 this all is) I see that it does the forward and then returns a
boolean, true if no errors occur or false otherwise, so it doesn't look
like I have the opportunity to do something like the following
psuedo-code:

myOverriden_ProcessValidate() {

  boolean b = super.processValidate();
  if (!b) {
    forward to my jsp
  }

}

... because by the time I hit my check of b, the forward or redirect has
already been done.  Is it possible to override the forward or redirect
that the super.processValidate() could do?  I didn't think so.  Am I
missing the obvious somewhere on how to do this, or maybe I'm barking up
the wrong tree to begin with?  Thanks all!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Extending RequestProcessor to handle validation errors

Posted by Joe Germuska <Jo...@Germuska.com>.
With the ComposableRequestProcessor, the validation is independent 
from the command which puts an ActionForward into the context in the 
event of a failed form validation.  It should be very straightforward 
for you to change the "SelectInput" command or add another one which 
uses request context information to decide whether it should override 
the normal behavior or assume that some other command will handle 
things.

Joe


At 12:38 PM -0500 2/2/05, Frank W. Zammetti (MLists) wrote:
>Hi folks... I'm working on an update of my Struts Web Services project,
>and I can't seem to work out how to do something...
>
>What I want to do is have a way to redirect to a given JSP when ActionForm
>validation errors occur that will OVERRIDE whatever might be configured in
>the action mapping.  In other words... in a normal application, validation
>errors occur and we get forwarded back to the input page.  I want to be
>able to redirect to a different JSP, REGARDLESS of what the input page is.
>
>I looked at overriding the processValidate() method of RequestProcessor,
>but I don't see how that can work... Looking at the source of the original
>RP (v1.1 this all is) I see that it does the forward and then returns a
>boolean, true if no errors occur or false otherwise, so it doesn't look
>like I have the opportunity to do something like the following
>psuedo-code:
>
>myOverriden_ProcessValidate() {
>
>   boolean b = super.processValidate();
>   if (!b) {
>     forward to my jsp
>   }
>
>}
>
>... because by the time I hit my check of b, the forward or redirect has
>already been done.  Is it possible to override the forward or redirect
>that the super.processValidate() could do?  I didn't think so.  Am I
>missing the obvious somewhere on how to do this, or maybe I'm barking up
>the wrong tree to begin with?  Thanks all!
>
>--
>Frank W. Zammetti
>Founder and Chief Software Architect
>Omnytex Technologies
>http://www.omnytex.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>For additional commands, e-mail: dev-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org