ICEfaces
  1. ICEfaces
  2. ICE-3084

<ice:selectOneMenu/> with empty first value causing unnecessary DOM updates

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7
    • Fix Version/s: 1.7.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      ICEfaces 1.7 + Liferay 4.2.2 + Tomcat 6.0.16

      Description

      I don't know this for sure, but I suspect this isn't just a portlet problem, but a webapp problem in general.

      Webapp developers typically have <ice:selectOneMenu/> components that are bound to a database column. Often times, the database column is NULL, and therefore has no initial value. In this case, a typical thing to do is to make the first SelectItem be something like this:

           selectItems.add(new SelectItem("", "-- Select --"));

      However, when this is used done on a page with other fields that have partialSubmit=true, the DOM for the selectItems is always updated, even though the selectItems in the list haven't changed.

      In order to reproduce this problem, follow these steps:

      1. Download the Liferay 4.4.2 + Tomcat 6.0.16 bundle
      2. Run startup.bat
      3. Download the attached .WAR and copy it to your $HOME/username/liferay/deploy folder
      4. Monitor the Tomcat console log to make sure the portlet deploys correctly
      5. Startup FireFox
      6. Visit http://localhost:8080
      7. Login to the portal as test@liferay.com with password test
      8. Navigate to the private pages in "My Community"
      9. Add a new portal page named "ICE"
      10. Click on the new ICE tab
      11. Add the portlet to the page (found under the samples category)
      12. Startup FireBug
      13. Click on the FireBug CONSOLE tab
      14. In the FireBug Search box, type: applied update
           ** note that this will filter the FireBug console so that only DOM updates will be shown **
      15. Click in the "First Name" field
      16. Press the tab key on the keyboard to cause an onblur event

      If the bug is fixed, there will be no DOM updates shown in the FireBug console.

      If the bug is still there, aDOM update like the following will appear in the FireBug console:

      <select class="iceSelOneMnu portlet-form-field" id="_ice_" name="_ice_:_id2:_id5:0:phoneNumberType" onblur="setFocus(&#39;&#39;);" onchange="setFocus(&#39;&#39;);iceSubmitPartial(form, this, event);" onfocus="setFocus(this.id);" size="1">...</select>

      This is a bug because the model has not changed with respect to the value of the <ice:selectOneMenu/> component.

      Note that this only happens with the first SelectItem has an EMPTY string value. If a value like "foo" is passed, then the DOM update doesn't happen.

        Activity

        Hide
        Neil Griffin added a comment -

        Forgot to mention that on a page where there are drop down lists that contain MANY MANY values, that the unnecessary DOM updates really slow the partialSubmit process down

        Show
        Neil Griffin added a comment - Forgot to mention that on a page where there are drop down lists that contain MANY MANY values, that the unnecessary DOM updates really slow the partialSubmit process down
        Hide
        Ken Fyten added a comment -

        Please review this case to see if it's related to ICE-1985.

        Show
        Ken Fyten added a comment - Please review this case to see if it's related to ICE-1985 .
        Hide
        Adnan Durrani added a comment -

        Its not related to the ICE-1985.

        I am not able to reproduce it with the trunk head. Neil can you please retest it. If you still see the problem then can you please initialize the following property "phoneNumberType" with the blank string in the "viewBean".

        There is a known issue with the stock JSF, that the all UISelect types of components gets initialized with the null values in the component tree, and on the first page submit request they receive a blank string which causes their valueChangeListener to get fired.

        Show
        Adnan Durrani added a comment - Its not related to the ICE-1985 . I am not able to reproduce it with the trunk head. Neil can you please retest it. If you still see the problem then can you please initialize the following property "phoneNumberType" with the blank string in the "viewBean". There is a known issue with the stock JSF, that the all UISelect types of components gets initialized with the null values in the component tree, and on the first page submit request they receive a blank string which causes their valueChangeListener to get fired.
        Hide
        Neil Griffin added a comment -

        I'm still able to reproduce this with the trunk head and also with the 1.7.x branch.

        Also, I tried setting phoneNumberType to a blank string in ViewBean and that only helps temporarily. After I complete the first name and last name fields, and then press tab, or clear out one of the names, and hit tab again, I get "applied update" to the selectItems of the ice:selectOneMenu component.

        Show
        Neil Griffin added a comment - I'm still able to reproduce this with the trunk head and also with the 1.7.x branch. Also, I tried setting phoneNumberType to a blank string in ViewBean and that only helps temporarily. After I complete the first name and last name fields, and then press tab, or clear out one of the names, and hit tab again, I get "applied update" to the selectItems of the ice:selectOneMenu component.
        Hide
        Adnan Durrani added a comment -

        Yes I am able to reproduce it.

        Show
        Adnan Durrani added a comment - Yes I am able to reproduce it.
        Hide
        Adnan Durrani added a comment -

        trunk revision: 16808
        branch 1.7 revision: 16809

        Show
        Adnan Durrani added a comment - trunk revision: 16808 branch 1.7 revision: 16809
        Hide
        Adnan Durrani added a comment -

        Neil can you please verify it.

        Thanks,

        Show
        Adnan Durrani added a comment - Neil can you please verify it. Thanks,

          People

          • Assignee:
            Unassigned
            Reporter:
            Neil Griffin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: