You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "J Alex (JIRA)" <ji...@apache.org> on 2007/06/07 15:15:26 UTC

[jira] Created: (STR-3049) Specifying Dispatcher based validations in validation.xml

Specifying Dispatcher based validations in validation.xml
---------------------------------------------------------

                 Key: STR-3049
                 URL: https://issues.apache.org/struts/browse/STR-3049
             Project: Struts 1
          Issue Type: Improvement
          Components: Core
         Environment: N/A
            Reporter: J Alex


I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.

The method should be independent of javascript.

Scenario : 

Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.

Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.

We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.

i.e 
myForm.setPage(1);

I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.


ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STR-3049) Specifying Dispatcher based validations in validation.xml

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated STR-3049:
-------------------------------

    Assignee:     (was: J Alex)

> Specifying Dispatcher based validations in validation.xml
> ---------------------------------------------------------
>
>                 Key: STR-3049
>                 URL: https://issues.apache.org/struts/browse/STR-3049
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>         Environment: N/A
>            Reporter: J Alex
>            Priority: Minor
>
> I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.
> The method should be independent of javascript.
> Scenario : 
> Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.
> Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.
> We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.
> i.e 
> myForm.setPage(1);
> I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.
> ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STR-3049) Specifying Dispatcher based validations in validation.xml

Posted by "J Alex (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

J Alex updated STR-3049:
------------------------

    Priority: Minor  (was: Major)

> Specifying Dispatcher based validations in validation.xml
> ---------------------------------------------------------
>
>                 Key: STR-3049
>                 URL: https://issues.apache.org/struts/browse/STR-3049
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>         Environment: N/A
>            Reporter: J Alex
>            Assignee: J Alex
>            Priority: Minor
>
> I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.
> The method should be independent of javascript.
> Scenario : 
> Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.
> Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.
> We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.
> i.e 
> myForm.setPage(1);
> I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.
> ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STR-3049) Specifying Dispatcher based validations in validation.xml

Posted by "J Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/STR-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41198 ] 

J Alex commented on STR-3049:
-----------------------------

This method works for me for now. I can try providing a hook to tie the dispatchmethod to the <form> entries in validation.xml. Assigning the task to myself.

> Specifying Dispatcher based validations in validation.xml
> ---------------------------------------------------------
>
>                 Key: STR-3049
>                 URL: https://issues.apache.org/struts/browse/STR-3049
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>         Environment: N/A
>            Reporter: J Alex
>
> I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.
> The method should be independent of javascript.
> Scenario : 
> Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.
> Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.
> We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.
> i.e 
> myForm.setPage(1);
> I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.
> ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STR-3049) Specifying Dispatcher based validations in validation.xml

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/STR-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41190 ] 

Niall Pemberton commented on STR-3049:
--------------------------------------

Yes it is possible - just means duplicating some of the "dispatch" logic in the ActionForm.

ActionForm implementations which support Commons Validator have a getValidationKey() method - so this can be used to hook into different validation rules for dispatch style actions. So using the vanilla "DispatchAction" as an example - if you wanted to say use a composite key (in Commons Validator) of the ActionForm name plus the dispatch parameter - you could do something like the following:

public class CustomerDispatchValidatorForm extends ValidatorForm {

    public String getValidationKey(ActionMapping mapping, HttpServletRequest request) {

        String parameterName = mapping.getParameter();
        String parameterValue = request.getParameter(parameterName);
        String formName =  mapping.getName();      
        return formName + "-"  + parameterValue;

    }

}

Then in your struts-config.xml....

    <form-beans>
        <form-bean  name="customerForm" type="mypackage.CustomerDispatchValidatorForm">
    </form-beans>

    <action path="/customer" 
                  type="mypackage.CustomerDispatchAction" 
                  name="customerForm" 
                  validate="true" 
                  parameter="method" 
                  input="...">
        <forward ... />
    </action>

if the "method" parameter could be submitted with values "add", "update" and "delete" - then in the validation.xml you would have forms with the following keys:

<form-validation>
    <formset>

        <form name="customerForm-add">
        </form>

        <form name="customerForm-update">
        </form>

        <form name="customerForm-delete">
        </form>

    </formset>
</form-validation>




> Specifying Dispatcher based validations in validation.xml
> ---------------------------------------------------------
>
>                 Key: STR-3049
>                 URL: https://issues.apache.org/struts/browse/STR-3049
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>         Environment: N/A
>            Reporter: J Alex
>
> I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.
> The method should be independent of javascript.
> Scenario : 
> Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.
> Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.
> We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.
> i.e 
> myForm.setPage(1);
> I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.
> ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (STR-3049) Specifying Dispatcher based validations in validation.xml

Posted by "J Alex (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

J Alex reassigned STR-3049:
---------------------------

    Assignee: J Alex

> Specifying Dispatcher based validations in validation.xml
> ---------------------------------------------------------
>
>                 Key: STR-3049
>                 URL: https://issues.apache.org/struts/browse/STR-3049
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>         Environment: N/A
>            Reporter: J Alex
>            Assignee: J Alex
>
> I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.
> The method should be independent of javascript.
> Scenario : 
> Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.
> Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.
> We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.
> i.e 
> myForm.setPage(1);
> I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.
> ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STR-3049) Specifying Dispatcher based validations in validation.xml

Posted by "J Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/STR-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41187 ] 

J Alex commented on STR-3049:
-----------------------------

Niall, thanks for your comment. What do you think is the best possible workaround for this scenario ? . Is it possible to set validate=true and still achieve section-wise validation , without explicitly invoking it from the Action.



> Specifying Dispatcher based validations in validation.xml
> ---------------------------------------------------------
>
>                 Key: STR-3049
>                 URL: https://issues.apache.org/struts/browse/STR-3049
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>         Environment: N/A
>            Reporter: J Alex
>
> I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.
> The method should be independent of javascript.
> Scenario : 
> Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.
> Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.
> We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.
> i.e 
> myForm.setPage(1);
> I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.
> ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STR-3049) Specifying Dispatcher based validations in validation.xml

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/STR-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41185 ] 

Niall Pemberton commented on STR-3049:
--------------------------------------

Yes you're right there is no way to specify a mapping between the dispatch methods and the validations declaratively.

The problem is that we have various flavours of Disptach action (vanilla, lookup, mapping, event) and they use various mechanisms to the determine the dispatch method - the logic of which is all locked in each of the DispatchAction implementations. So the trick is going to be coming up with a mechanism which supports each of those flavours. So someone needs to come up with a good solution for this issue to have any chance - otherwise we should close as WONT FIX. 


> Specifying Dispatcher based validations in validation.xml
> ---------------------------------------------------------
>
>                 Key: STR-3049
>                 URL: https://issues.apache.org/struts/browse/STR-3049
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>         Environment: N/A
>            Reporter: J Alex
>
> I want to confirm if there's a way to specify a mapping between the dispatch methods and the validations declaratively.
> The method should be independent of javascript.
> Scenario : 
> Consider a single-page form (i.e  single  HTML <form> mapping to say /myAction.do ) with many sections, each section having its own Submit button. On submit of each, ONLY the fields within that section must be validated.
> Using DispatchAction to handle each submit button takes care of centralizing the handler methods and making the Action classes crisp. But, when it comes to validation, there's no way to specify in validation.xml the fields tied to a specific dispatch method.
> We could use the "page" parameter to delimit the validations, but this cannot be done declaratively since we cannot dynamically change the "page" using javascript on a particular submit. The workaround is to set validate=false, and explicitly invoke validation from the Action class after setting the "page" within each dispatcher method.
> i.e 
> myForm.setPage(1);
> I think it will be a good enhancement to provide this mapping within Struts itself which i feel will greatly enhance the utility of DispatchAction.
> ActionMessages errors = myForm.validate( mapping, request );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.