struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Re: Pulling Punches
Date Tue, 22 Jun 2004 00:35:22 GMT
Niall Pemberton wrote:

>More info on the circumstances would be helpful..
>
>1) How Often - just for one particular Action, for all Actions or somewhere
>in between?
>  
>
I'm looking for a generic solution for about 6 to 10 Actions that all 
work on a set of objects.

>2) What kind of ActionForms are you using - regular or DynaActionForm?
>  
>
Regular

>3) Are you using the validator framework?
>
>  
>
No, just validate(...) methods.

>Having said that there are a number of possibilities
>
>1) Put the check in the ActionForm validate method, before you do your other
>validations.
>  
>
Problem is, I can't forward from the ActionForm, if an error occurs then 
its off to "input" before I could forward in the Action.

>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();
>      errors.add(....);
>      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();
>   }
>
>  
>
This is probibly the approach I will need to take.

>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.
>
>  
>
Oof, not sure I want to go that far yet.

-thanks!
Mark



Mime
View raw message