You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Stefan Meyer (JIRA)" <de...@myfaces.apache.org> on 2009/06/08 09:14:07 UTC

[jira] Created: (EXTVAL-46) Referencing other properties for the skip validation strategy

Referencing other properties for the skip validation strategy
-------------------------------------------------------------

                 Key: EXTVAL-46
                 URL: https://issues.apache.org/jira/browse/EXTVAL-46
             Project: MyFaces Extensions Validator
          Issue Type: New Feature
            Reporter: Stefan Meyer


I would like to skip validation of property a based on an evaluation of properpty b. Similar to RequiredIf but as powerfull as skipvalidation - basically an extension to skipvalidation.

Extval seems to be validating in more than one phase.  So the skip validation stuff seems to be over when cross validation begins. That is why i did not try really hard to do it.



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


[jira] Commented: (EXTVAL-46) Referencing other properties for the skip validation strategy

Posted by "Gerhard Petracek (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/EXTVAL-46?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12718383#action_12718383 ] 

Gerhard Petracek commented on EXTVAL-46:
----------------------------------------

#1
do you mean a constraint level conditional validation?

#2 (fyi)
extval validations are performed completely in the "process validations"-phase of jsf.
(cross-validation is invoked via a phase-listener after the validation phase - but before the next phase starts
-> as expected - no model update happens in case of a violation...)

regards,
gerhard

> Referencing other properties for the skip validation strategy
> -------------------------------------------------------------
>
>                 Key: EXTVAL-46
>                 URL: https://issues.apache.org/jira/browse/EXTVAL-46
>             Project: MyFaces Extensions Validator
>          Issue Type: New Feature
>            Reporter: Stefan Meyer
>
> I would like to skip validation of property a based on an evaluation of properpty b. Similar to RequiredIf but as powerfull as skipvalidation - basically an extension to skipvalidation.
> Extval seems to be validating in more than one phase.  So the skip validation stuff seems to be over when cross validation begins. That is why i did not try really hard to do it.

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


[jira] Commented: (EXTVAL-46) Referencing other properties for the skip validation strategy

Posted by "Gerhard Petracek (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/EXTVAL-46?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12719335#action_12719335 ] 

Gerhard Petracek commented on EXTVAL-46:
----------------------------------------

the common solution:
you can use the rendered attribute of your component(s) and hide all options which won't make sense (due to an other selection).
that's also better for the user - just display information which are really needed.

or do you try to reduce server roundtrips?
in such a case you could use an add-on like:
http://os890.blogspot.com/2009/06/myfaces-extval-add-on-conditional.html
as condition use a property of a bean to resolve the result or you can directly reference a request value.
any el-expression which results in a boolean result is valid.

an attribute to reference a special component-id won't be proper in this case, because you would bind your model to a specific part of a page or you force the same component-id if you have a second page which uses the same property. if you don't care about that, you are free to impl. your own version of @SkipValidation which provides such an attribute. extval is very pluggable. as you can see at the os890 add-ons it's quite easy to add/remove metadata for a special property based on any condition/mechanism. if you need any help for your requirement, you know how to contact me directly. we already implemented such use-cases without problems. since there are existing solutions and/or possibilities, i would like to close this feature-request. (however, i'm also available for further discussions.)

--

fyi:
i don't really know what you mean with "second validation phase" - if you call cross-validation the 2nd validation phase, it's not true. cross-validation gets triggered within the normal validation phase and so @SkipValidation works the same way for both.

hint:
@Required isn't needed, if you are using a custom value at the minimum attribute of @Length. so you can reduce metadata hosted by a property. use @Required, if you don't have @Length at your property (or @Length just provides a maximum) or you would like to display a special required violation message or you would like to use severity aware validation for just one of the two constraints or ...

> Referencing other properties for the skip validation strategy
> -------------------------------------------------------------
>
>                 Key: EXTVAL-46
>                 URL: https://issues.apache.org/jira/browse/EXTVAL-46
>             Project: MyFaces Extensions Validator
>          Issue Type: New Feature
>            Reporter: Stefan Meyer
>
> I would like to skip validation of property a based on an evaluation of properpty b. Similar to RequiredIf but as powerfull as skipvalidation - basically an extension to skipvalidation.
> Extval seems to be validating in more than one phase.  So the skip validation stuff seems to be over when cross validation begins. That is why i did not try really hard to do it.

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


[jira] Commented: (EXTVAL-46) Referencing other properties for the skip validation strategy

Posted by "Stefan Meyer (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/EXTVAL-46?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12718410#action_12718410 ] 

Stefan Meyer commented on EXTVAL-46:
------------------------------------

I want to use the skipvalidation conditional expression to use componente values - as in cross validation.

Very common example:

The user may choose between two payment types via radio buttons. between the radio buttons are the text fields associated with those payment types:

(0) credit
  creditcardnumber [                        ]
  institute [               ]
( ) debit
  bankcode [                ]
  accountnumber [            ]

My model looks like this:

class Form {

@Required
private PaymentTypeEnum paymentType;

@SkipValidation(input={"paymentType"},"${0}!='CREDIT')
@Required
@Length(minimum = 6, maximum = 20)
private String creditcardnumber ;

@SkipValidation(input={"paymentType"},"${0}!='CREDIT')
@Required
@Length(minimum = 6, maximum = 20)
private String institute ;

@SkipValidation(input={"paymentType"},"${0}!='DEBIT')
@Required
@Length(minimum = 6, maximum = 20)
private String bankcode ;

@SkipValidation(input={"paymentType"},"${0}!='DEBIT')
@Required
@Length(minimum = 6, maximum = 20)
private String accountnumber ;

}

I want to skip validation for the fields that are not associated with the selected payment type.

I suggest a property "input" for skipValidation that defines other properties to be referenced by index (${i}) in the expression. The issue I see is that this skipoValidation can only be eceuted in extval's second validation phase and thus is not effective for the validations in the first phase. One would actually have to move all validations to the second phase??!!!




> Referencing other properties for the skip validation strategy
> -------------------------------------------------------------
>
>                 Key: EXTVAL-46
>                 URL: https://issues.apache.org/jira/browse/EXTVAL-46
>             Project: MyFaces Extensions Validator
>          Issue Type: New Feature
>            Reporter: Stefan Meyer
>
> I would like to skip validation of property a based on an evaluation of properpty b. Similar to RequiredIf but as powerfull as skipvalidation - basically an extension to skipvalidation.
> Extval seems to be validating in more than one phase.  So the skip validation stuff seems to be over when cross validation begins. That is why i did not try really hard to do it.

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