Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-13127

onvalid and oninvalide pass wrong element when using rich:element with String field

    Details

    • Steps to Reproduce:
      Hide
      1. unzip RF-13127.zip and open the folder
      2. run mvn jetty:run
      3. open http://localhost:8080/richfaces/home.faces
      1. change e.g. the third vin input to 'a'
        • expected: the third vin input is changed by the user function
        • have: the first vin input is changed by the user function
      1. change e.g. the third mileage input to 'a'
        • works correctly
      Show
      unzip RF-13127 .zip and open the folder run mvn jetty:run open http://localhost:8080/richfaces/home.faces change e.g. the third vin input to 'a' expected: the third vin input is changed by the user function have: the first vin input is changed by the user function change e.g. the third mileage input to 'a' works correctly

      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.

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

      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.

        Gliffy Diagrams

          Attachments

          1. JSFTemplate.zip
            93 kB
          2. RF-13127.zip
            13 kB
          3. richfaces.zip
            11 kB

            Activity

              People

              • Assignee:
                michpetrov Michal Petrov
                Reporter:
                parisila Louis Parisi
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 hour
                  1h
                  Remaining:
                  Remaining Estimate - 1 hour
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified