myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Comment Edited] (MYFACES-3547) Can't use expression for validator attributes
Date Wed, 19 Sep 2012 20:55:08 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-3547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459085#comment-13459085
] 

Mike Kienenberger edited comment on MYFACES-3547 at 9/20/12 7:54 AM:
---------------------------------------------------------------------

To answer my own question, the key is to create a custom Facelets validator MetaRule which
detects when an attribute value is non-literal.   In that case, the rule will call a custom
method to inject the ValueExpression rather than setting the attribute value directly.   The
validator or converter is responsible for storing the ValueExpression in state and then evaluating
it when needed.

MyFaces Commons provides a framework for making all of this happen with minimal effort.  However,
someone could simply create their own MetaRule based on the _ValidationRule in MyFaces Commons,
and do this themselves.

http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/_ValidatorRule.java?view=markup

This can be done for any version of JSF, although the details in the Facelets handler changed
starting in JSF 1.2.
                
      was (Author: mkienenb):
    To answer my own question, the key is to create a custom Facelets validator MetaRule which
detects when an attribute value is non-literal.   In that case, the rule will call a custom
method to inject the ValueExpression rather than setting the attribute value directly.   The
validator or converter is responsible for storing the ValueExpression in state and then evaluating
it when needed.

MyFaces Commons provides a framework for making all of this happen with minimal effort.  However,
someone could simply create their own MetaRule based on the _ValidationRule in MyFaces Commons,
and do this themselves.

http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/_ValidatorRule.java?view=markup

                  
> Can't use expression for validator attributes
> ---------------------------------------------
>
>                 Key: MYFACES-3547
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3547
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.1.7
>         Environment: validator ajax
>            Reporter: Deryk Sinotte
>            Priority: Minor
>         Attachments: validator.zip
>
>
> Attaching a test case that shows a problem when using an expression for an attribute
in a validator. We have markup that looks like this:
> <h:inputText id="ajaxMy"
> value="#{testBean.myNumber}">
> <f:validateLongRange minimum="1"
> maximum="#{testBean.maxValue}"/>
> <f:ajax execute="@this"
> render="@form"/>
> </h:inputText>
> When the value of the maximum attribute is modified via Ajax from another input field,
the value of the bean is properly set but the validator doesn't resolve appear to resolve
the expression at the right time and the result is that validation occurs against the "old"
values.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message