struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <>
Subject Re: Pulling Punches
Date Tue, 22 Jun 2004 00:18:44 GMT
More info on the circumstances would be helpful..

1) How Often - just for one particular Action, for all Actions or somewhere
in between?
2) What kind of ActionForms are you using - regular or DynaActionForm?
3) Are you using the validator framework?

Having said that there are a number of possibilities

1) Put the check in the ActionForm validate method, before you do your other
2) Set the validate="false" in the struts-config.xml - Struts won't then
call the ActionForm's validate() method. You could then do the check in your
Action and if its OK then call the ActionForm's validate method yourself
from the Action's execute method. Smething like...

   // Check if Stale
   ActionErrors errors = null;
   if (isStale()) {
      errors = new ActionErrors();
      saveErrors(request, errors);
      return mapping.getInputForward();

   // Do ActionForm validation
   errors = form.validate(mapping, request);
    if (errors != null && errors.size() > 0)
       saveErrors(request, errors);
       return mapping.getInputForward();

3) If its something you want to do for every Action you could put the above
option in a 'base' Action that you extend all your Action's from.
Alternatively you could implement your own custom RequestProcessor -
overriding the processValidate() method - you would have to duplicate the
code to forward to the input though.


----- Original Message ----- 
From: "Mark R. Diggory" <>
To: "Struts Users Mailing List" <>
Sent: Tuesday, June 22, 2004 12:32 AM
Subject: Pulling Punches

> Here's an interesting one for ya.
> I have a struts action in which I use the "input" parameter to forward
> back to the jsp when validation errors occur (pretty basic). There is an
> instance where an object could be stale once the browser gets into my
> Actions execute method, when this is encountered the action forwards to
> an error page that provides a message. This way if anyone bookmarks the
> action, I can show something better than a stack trace when they return
> to the page.
> My problem is that I get forwarded back to the input form without
> execute occuring and teh stale object being encountered! When returning
> via a bookmark, I get dumped into the JSP designated in the input
> attribute. Is there any way I can execute some code to verify the object
> is not stale BEFORE validation occurs?
> What it really boils down to is this. Is there a way I can cause an
> ActionForward before ActionForm.validate occurs?
> -Mark


> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message