ICEfaces
  1. ICEfaces
  2. ICE-8731

Can't clear input fields with patched Mojarra 2.1.3 jar

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.3
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Mojarra 2.1.3_P01
    • Assignee Priority:
      P1

      Description


      When using the patched Mojarra 2.1.3 jar it is not possible to clear out a non-ajax enabled h:inputText field. With the regular Mojarra 2.1.3 jar this is possible with the same code.

      My test also shows and issue with an ajax enabled input field not being cleared. Its possible that this is an issue with the patched jar and the code that is being called to clear/reset all input fields on the form.


      1. ICE-8731.patch
        3 kB
        Migration

        Activity

        Hide
        Deryk Sinotte added a comment - - edited

        Assignee: Mircea Toma (was: Ken Fyten)
        Re-opened and assigned to Mircea.

        Show
        Deryk Sinotte added a comment - - edited Assignee: Mircea Toma (was: Ken Fyten) Re-opened and assigned to Mircea.
        Hide
        Deryk Sinotte added a comment - - edited

        Attaching modified Mojarra 2.1.3 with both patches attached (jsf.js and UIComponentBase)

        Show
        Deryk Sinotte added a comment - - edited Attaching modified Mojarra 2.1.3 with both patches attached (jsf.js and UIComponentBase)
        Hide
        Mircea Toma added a comment - - edited

        Attached the patched Mojarra 2.1.3 patch. The patch is based on the latest patch submitted under http://java.net/jira/browse/JAVASERVERFACES-2461 case.

        Show
        Mircea Toma added a comment - - edited Attached the patched Mojarra 2.1.3 patch. The patch is based on the latest patch submitted under http://java.net/jira/browse/JAVASERVERFACES-2461 case.
        Hide
        Mircea Toma added a comment - - edited

        Before getting into the issue we have with the patched Mojarra it should be noted that the test case needs to be modified first. The TestBean.clear method invoked when the "Clear" button is clicked doesn't really clear the bound values rendered by the input text components present in the page. The test page should be modified to use the TestBean.altClear method instead.

        Show
        Mircea Toma added a comment - - edited Before getting into the issue we have with the patched Mojarra it should be noted that the test case needs to be modified first. The TestBean.clear method invoked when the "Clear" button is clicked doesn't really clear the bound values rendered by the input text components present in the page. The test page should be modified to use the TestBean.altClear method instead.
        Hide
        Deryk Sinotte added a comment - - edited

        As near as I can figure at the moment, the problem does seem to exist in the patched version of jsf.js that we have in 2.1.3. In there is a clone attributes function that we modified. In that function, we altered how attributes are copied. Here is the section that deals with input style elements specifically:

            var isInputElement = target.nodeName.toLowerCase() === 'input';
            var propertyNames = isInputElement ? coreElementProperties.concat(inputElementProperties) : coreElementProperties;
            for (var iIndex = 0, iLength = propertyNames.length; iIndex < iLength; iIndex++) {
                var propertyName = propertyNames[iIndex];
                var attributeName = propertyToAttribute(propertyName);
                if (sourceAttributeDetector(attributeName)) {
                    var newValue = source[propertyName];
                    var oldValue = target[propertyName];
                    if (oldValue != newValue) {
                        target[propertyName] = newValue;
                    }
                } else if (targetAttributeDetector(attributeName)) {
                    //setting property to '' seems to be the only cross-browser method for removing an attribute
                    target[propertyName] = '';
                }
            } 
        

        From my testing, I don't see either the sourceAttributeDetector() or targetAttributeDetector() conditions being satisfied which would mean the attribute never gets updated. This aligns with the fact that the response coming back from the server is correct in that the value has been cleared.
        Since this code is similar to the code we passed to the Mojarra team for inclusion in JSF for 2.1.15, we should make sure we don't have the same problem there.

        Show
        Deryk Sinotte added a comment - - edited As near as I can figure at the moment, the problem does seem to exist in the patched version of jsf.js that we have in 2.1.3. In there is a clone attributes function that we modified. In that function, we altered how attributes are copied. Here is the section that deals with input style elements specifically: var isInputElement = target.nodeName.toLowerCase() === 'input'; var propertyNames = isInputElement ? coreElementProperties.concat(inputElementProperties) : coreElementProperties; for ( var iIndex = 0, iLength = propertyNames.length; iIndex < iLength; iIndex++) { var propertyName = propertyNames[iIndex]; var attributeName = propertyToAttribute(propertyName); if (sourceAttributeDetector(attributeName)) { var newValue = source[propertyName]; var oldValue = target[propertyName]; if (oldValue != newValue) { target[propertyName] = newValue; } } else if (targetAttributeDetector(attributeName)) { //setting property to '' seems to be the only cross-browser method for removing an attribute target[propertyName] = ''; } } From my testing, I don't see either the sourceAttributeDetector() or targetAttributeDetector() conditions being satisfied which would mean the attribute never gets updated. This aligns with the fact that the response coming back from the server is correct in that the value has been cleared. Since this code is similar to the code we passed to the Mojarra team for inclusion in JSF for 2.1.15, we should make sure we don't have the same problem there.
        Hide
        Arran Mccullough added a comment - - edited

        Attached test case to reproduce issue.

        Show
        Arran Mccullough added a comment - - edited Attached test case to reproduce issue.
        Hide
        Arran Mccullough added a comment - - edited

        Another observation, if I set the value bound objects to null directly instead of the clear code, it still doesn't work with the patched jar. It does however work with the non-patched jar.

        Show
        Arran Mccullough added a comment - - edited Another observation, if I set the value bound objects to null directly instead of the clear code, it still doesn't work with the patched jar. It does however work with the non-patched jar.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Arran Mccullough
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: