[ 
https://issues.jboss.org/browse/RF-12831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12764387#comment-12764387
 ] 

Juraj Húska edited comment on RF-12831 at 4/2/13 9:40 AM:
----------------------------------------------------------

Thanks for minimizing the reproducer code.

However, I have some additional questions.

# If I understand it correctly you are asserting that the 
{{modelBean.model.field1}} is equal to the value which is going to be 
validated. IMHO it cannot be true. The value need to be firstly validated by 
validator, then it is set to the model. That is the purpose of the validator, 
isn't it ?
# Secondly, you are using the same validator binding for the second 
{{inputText}}, however, it can not pass neither, because the value being 
validated is compared with the {{field1}} value, instead of {{field2}} value

Am I correct, or am I missing something ?
                
      was (Author: jhuska):
    Thanks for minimizing the reproducer code.

However, I have some additional questions.

# If I understand it correctly you are asserting that the 
{{modelBean.model.field1}} is equal to the value which is going to be 
validated. IMHO it cannot be true. The value need to be firstly validated by 
validator, then it is set to the model. That is the purpose of the validator, 
isn't it ?
# Secondly, you are using the same validator binding for the second 
{{inputText}}, however, it can not pass neither, because the value being 
validated is compared with the {{field1}} value, instead of {{field2}} value

Am I correct, or I am missing something ?
                  
> <rich:validator/> performs ajax validation without updating underlying model 
> field
> ----------------------------------------------------------------------------------
>
>                 Key: RF-12831
>                 URL: https://issues.jboss.org/browse/RF-12831
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 4.3.0.Final
>         Environment: JBoss eap 6.0.0, Win 7
>            Reporter: Kamil Roman
>            Assignee: Juraj Húska
>            Priority: Minor
>         Attachments: rf-12831.zip
>
>
> Not sure if it's a bug or a feature, but field annotated with 
> {code}<rich:validator/>{code} with a validation method set with 
> {code}validator{code} attribute gets validated without updating the 
> underlying model field. My code is something like this:
> {code:title=Model.java}
> public class Model {
> //...
> public Date getValidFrom() {/*...*/}
> public Date getValidTo() {/*...*/}
> }
> {code}
> {code:title=ModelValidator.java}
> public class ModelValidator{
> private Model model;
> public boolean isValidToAfterValidFrom() {
>       return model.getValidTo().after(model.getValidFrom());          
>       }
> }
> {code}
> {code:title=model_form.xml}
> <c:set var="model" value="#{ModelBean.model}"/>
> <h:outputLabel value="#{labels.getLabel('valid_from')}"       for="validFrom" 
> /> 
> <rich:calendar        value="#{model.validFrom}" id="validFrom" >
>       <rich:validator/>
> </rich:calendar>
> <rich:message for="validFrom"/>       
>                                                                       
> <h:outputLabel value="#{labels.getLabel('valid_to')}" for="validTo" /> 
> <rich:calendar value="#{model.validTo}" id="validTo" 
> validator="#{modelBean.validateValidTo}">
>       <rich:validator event="inputblur"/>
> </rich:calendar>
> <rich:message for="validTo"/>
> {code}
> {code:title=ModelBean.java}
> public class ModelBean {
> public Model getModel() {/*..*/}
> private ModelValidator validator;
> //...
> public validateValidTo(FacesContext context, UIComponent toValidate, Object 
> value) {
>       if(!validator.isValidToAfterValidFrom()) {
>               FacesMessage message = new 
> FacesMessage(FacesMessage.SEVERITY_ERROR, 
> labelBean.getLabel("valid.to.not.after.valid.from.error"), null);
>               throw new ValidatorException(message);
>       }
> }
> {code}
> The getModel() method returns the same Model instance as is used by the 
> ModelValidator in ModelBean.
> Now, the testcase is:
> 1. User selects validTo earlier than ValidFrom (on a valid Model instance)
> 2. Validation passes as the underlying model value is not updated (validator 
> refers to the same Model instance as ModelBean)
> 3. User submits the form.
> 4. System displays error message as server-side validation on submit is 
> performed after applying request values.
> 5. User corrects the value in validTo field.
> 6. System still displays error message as validation fails, because the new 
> value is not applied to the model (model holds the invalid value applied 
> during failed submit).
> If this is not a bug, but a feature, it would be great if you included this 
> behaviour in the docs!

--
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

_______________________________________________
richfaces-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/richfaces-issues

Reply via email to