You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Bob Tiernay (JIRA)" <ji...@apache.org> on 2008/05/24 17:50:07 UTC

[jira] Created: (WW-2656) Support for Validation of Indexed Properties

Support for Validation of Indexed Properties
--------------------------------------------

                 Key: WW-2656
                 URL: https://issues.apache.org/struts/browse/WW-2656
             Project: Struts 2
          Issue Type: Improvement
          Components: Core Interceptors
    Affects Versions: 2.0.11
            Reporter: Bob Tiernay


Currently, there doesn't seem to be a method of validating an indexed property (ie. a collection)  directly or indirecetly within an action.

For instance, given an action OrderAction with a property order of type Order where order contains a collection trades of type Trade, the following is not possible:

@Validation
public class OrderAction {
	private Order order = new Order();

	@Validations(
		requiredFields = {
			@RequiredFieldValidator(message = "", key = "errors.required", fieldName = "order.trades[].field1"),
			@RequiredFieldValidator(message = "", key = "errors.required", fieldName = "order.trades[].field2"),
		}
	)	
	public String execute() throws Exception {
		....
                      }

The closest thing to support for something like the above is using the VisitorFieldValidator validator. Although it has the following disadvantages:
1. It must be placed on the target object (invasive and not context sensitive)
2. It does not work with an indirect collection  (as in the example above)

Something like this should be possible (even struts1 validator supports indexedListProperty)

On a related topic, it should be possible to do the following to display the error in the resulting view:

<s:fielderror><s:param>order.trades[2].field1</s:param></s:fielderror>

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


[jira] Updated: (WW-2656) Support for Validation of Indexed Properties

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

Don Brown updated WW-2656:
--------------------------

    Fix Version/s: Future

> Support for Validation of Indexed Properties
> --------------------------------------------
>
>                 Key: WW-2656
>                 URL: https://issues.apache.org/struts/browse/WW-2656
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Interceptors
>    Affects Versions: 2.0.11
>            Reporter: Bob Tiernay
>             Fix For: Future
>
>
> Currently, there doesn't seem to be a method of validating an indexed property (ie. a collection)  directly or indirecetly within an action.
> For instance, given an action OrderAction with a property order of type Order where order contains a collection trades of type Trade, the following is not possible:
> @Validation
> public class OrderAction {
> 	private Order order = new Order();
> 	@Validations(
> 		requiredFields = {
> 			@RequiredFieldValidator(message = "", key = "errors.required", fieldName = "order.trades[].field1"),
> 			@RequiredFieldValidator(message = "", key = "errors.required", fieldName = "order.trades[].field2"),
> 		}
> 	)	
> 	public String execute() throws Exception {
> 		....
>                       }
> The closest thing to support for something like the above is using the VisitorFieldValidator validator. Although it has the following disadvantages:
> 1. It must be placed on the target object (invasive and not context sensitive)
> 2. It does not work with an indirect collection  (as in the example above)
> Something like this should be possible (even struts1 validator supports indexedListProperty)
> On a related topic, it should be possible to do the following to display the error in the resulting view:
> <s:fielderror><s:param>order.trades[2].field1</s:param></s:fielderror>

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