Okay. Here is what I do which may or may not help.

I have subclassed DispatchAction to handle image buttons. 
The newer Struts version may handle this, but it didn't prior
to 1.1. Image buttons may not be your problem but it has a special
method to extract the dispatched operation. 
Anyhow you can see the implementation here.

http://issues.apache.org/bugzilla/show_bug.cgi?id=19925


I also subclass DynaValidatorActionForm which uses the static method defined
in ImageButtonDispatchAction to "extract" the operation parameter.

 /**
     * Validate the properties that have been set from this HTTP request,
     * and return an <code>ActionErrors</code> object that encapsulates any
     * validation errors that have been found.  If no errors are found, return
     * <code>null</code> or an <code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * @param mapping The mapping used to select this instance.
     * @param request The servlet request we are processing.
     * @return ActionErrors containing validation errors.
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        // set the page variable before validating
        Map props = this.getMap();
        if (props.containsKey("page")) {
            this.page = ((Integer) props.get("page")).intValue();
        }
        
        ServletContext application = getServlet().getServletContext();
        ActionErrors errors = new ActionErrors();
        String validationKey = this.getValidationKey(mapping, request);
                
                logger.fine("validationKey: " + validationKey);
                
        Validator validator =
            Resources.initValidator(
            validationKey, this, application, request, errors, page);
                logger.fine("validator: " + validator.getClass().getName());
                
        try {
            validatorResults = validator.validate();
        } catch (ValidatorException e) {
            log.error(e.getMessage(), e);
        }

        return errors;
    }
            
        
        /**
         * Get the validation key used to determine which validation
         * rules will be executed. 
         * 
         * @return the validation key
         */
        protected String getValidationKey(ActionMapping mapping, HttpServletRequest 
request) {
        
                String path = mapping.getPath(); 
                String parameter = mapping.getParameter();
                
                if (parameter == null) {
                
                        return path;
                
                }
                
                String operation = ImageButtonDispatchAction.getOperation(parameter, 
request);
                return  MessageFormat.format(
                                        VALIDATION_KEY_TEMPLATE, new Object[]{path, 
operation});
                        
                
        }




This allows me to have "validation keys" of the form: "path-operation".
So in my validation.xml I have form elements that look somewhat like:

<form name="/applications/account/doSaveChanges-create">

</form>

<form name="/applications/account/doSaveChanges-update">

</form>

As you can see, the same action mapping path is used but the operation
is appended to them allowing for more granular validations.

This may not be the best way to handle things, but I've been using
this approach for a couple years and it works quite well. 


robert


> -----Original Message-----
> From: Wendy Smoak [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 05, 2004 2:00 PM
> To: Struts Users Mailing List
> Subject: RE: Validation help for same Form, multiple pages/tabs
> 
> 
> Robert wrote:
> > Are you using DispatchAction or LookupDispatchAction? 
> 
> LookupDispatchAction.  And even worse, it's a cookie that controls which
> "tab" to show, not always a request parameter.  I think I may have
> painted myself into a corner...
> 
> -Wendy Smoak
> 
> ---------------------------------------------------------------------
> 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