[ 
https://issues.jboss.org/browse/RF-13127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Brian Leathem updated RF-13127:
-------------------------------

    Description: 
I have a bean iterated in a datatable.  Using the rich:validator on fields in 
the bean I am executing javascript when a field is validated and apply styling 
based on valid or invalid state.  The code below returns the correct element 
when the underlying field is a BigDecimal but intermittently returns the 
element from row zero and sometimes another rown when the field is a String.  
If I just reference a String vs. BigDecimal and display the element passed to 
the javascript I get form:myTable:4:myField for a BigDecimal field and always 
form:myTable:0:myField no matter the row for a String field.

{code}
<h:inputText id="vendor" value="#{car.vendor}" 
valueChangeListener="#{car.valueChanged}">
    <rich:validator oninvalid="valueModified(#{rich:element('vendor')}, false)"
                    onvalid="valueModified(#{rich:element('vendor')}, 
true)"/>{code}
</h:inputText>
{code}

{code}
<script>
    function valueModified(element, valid) {
        // use element.style rather than jQuery as it
        // does not set entire background
        alert("valueModified: " + element.id + " | valid: " + valid);
        element.style.background='yellow';
        if (valid) {
          jQuery(element).css("border-color", "lightgray");
        } else {
          jQuery(element).css("border-color", "red");
        }
      }
    </script>
{code}

Some other tests I did while trying to debug are:
* I passed the rowKeyVar to a javascript method in the onvalid event and it 
passed the correct row for a BigDecimal and always zero for a String field.
* The oncomplete event of the validator does not seem to fire for a String 
field but does for a BigDecimal field.


  was:
I have a bean iterated in a datatable.  Using the rich:validator on fields in 
the bean I am executing javascript when a field is validated and apply styling 
based on valid or invalid state.  The code below returns the correct element 
when the underlying field is a BigDecimal but intermittently returns the 
element from row zero and sometimes another rown when the field is a String.  
If I just reference a String vs. BigDecimal and display the element passed to 
the javascript I get form:myTable:4:myField for a BigDecimal field and always 
form:myTable:0:myField no matter the row for a String field.

{code}
<h:inputText value="#{myBean.myField}" id="myField">              
  <rich:validator oninvalid="valueModifiedAndError(#{rich:element('myField')})"
                  onvalid="valueModified(#{rich:element('myField')})"/>         
             
</h:inputText>
{code}

{code}
<script>
    function valueModified(element, valid) {
        // use element.style rather than jQuery as it
        // does not set entire background
        alert("valueModified: " + element.id + " | valid: " + valid);
        element.style.background='yellow';
        if (valid) {
          jQuery(element).css("border-color", "lightgray");
        } else {
          jQuery(element).css("border-color", "red");
        }
      }
    </script>
{code}

Some other tests I did while trying to debug are:
* I passed the rowKeyVar to a javascript method in the onvalid event and it 
passed the correct row for a BigDecimal and always zero for a String field.
* The oncomplete event of the validator does not seem to fire for a String 
field but does for a BigDecimal field.



    
> onvalid and oninvalide pass wrong element when using rich:element with String 
> field
> -----------------------------------------------------------------------------------
>
>                 Key: RF-13127
>                 URL: https://issues.jboss.org/browse/RF-13127
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-validators
>    Affects Versions: 4.3.3
>            Reporter: Louis Parisi
>         Attachments: JSFTemplate.zip
>
>
> I have a bean iterated in a datatable.  Using the rich:validator on fields in 
> the bean I am executing javascript when a field is validated and apply 
> styling based on valid or invalid state.  The code below returns the correct 
> element when the underlying field is a BigDecimal but intermittently returns 
> the element from row zero and sometimes another rown when the field is a 
> String.  If I just reference a String vs. BigDecimal and display the element 
> passed to the javascript I get form:myTable:4:myField for a BigDecimal field 
> and always form:myTable:0:myField no matter the row for a String field.
> {code}
> <h:inputText id="vendor" value="#{car.vendor}" 
> valueChangeListener="#{car.valueChanged}">
>     <rich:validator oninvalid="valueModified(#{rich:element('vendor')}, 
> false)"
>                     onvalid="valueModified(#{rich:element('vendor')}, 
> true)"/>{code}
> </h:inputText>
> {code}
> {code}
> <script>
>     function valueModified(element, valid) {
>         // use element.style rather than jQuery as it
>         // does not set entire background
>         alert("valueModified: " + element.id + " | valid: " + valid);
>         element.style.background='yellow';
>         if (valid) {
>           jQuery(element).css("border-color", "lightgray");
>         } else {
>           jQuery(element).css("border-color", "red");
>         }
>       }
>     </script>
> {code}
> Some other tests I did while trying to debug are:
> * I passed the rowKeyVar to a javascript method in the onvalid event and it 
> passed the correct row for a BigDecimal and always zero for a String field.
> * The oncomplete event of the validator does not seem to fire for a String 
> field but does for a BigDecimal field.

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