ICEfaces
  1. ICEfaces
  2. ICE-10621

ace:simpleSelectOneMenu doesn't iterate over non-SelectItem lists

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      Any
    • Assignee Priority:
      P1
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.)

      Description

      The following will not populate any items in the rendered dropdown:

      <ace:simpleSelectOneMenu value="#{bean.value}">
          <f:selectItems value="#{data.list}"/>
      </ace:simpleSelectOneMenu>

      If #{data.list} resolves to a non-SelectItem list, such as String[].

      However h:selectOneMenu had this functionality added (I think in JSF 2.1 or 2.2).

      Similarly using newer f:selectItems features don't seem to work. Such as:

      <ace:simpleSelectOneMenu value="#{bean.value}">
          <f:selectItems value="#{data.list}" var="loop" itemLabel="Custom #{loop}/>
      </ace:simpleSelectOneMenu>

      This should show "Custom #{loop}" as the label for each item, but the ace:simpleSelectOneMenu ignores the itemLabel attribute instead.

      Ideally ace:simpleSelectOneMenu would function, render, and process dropdowns the same as h:selectOneMenu, just with ICEfaces theming and options applied.

        Activity

        Hide
        Arturo Zambrano added a comment -

        r45036: added complete processing of the f:selectItems tag, in order to support non-SelectItem lists and arrays as well as newer attributes.

        Testing notes:
        Please create test cases for everything that's not already covered for testing the use of f:selectItems in ace:simpleSelectOneMenu (String array values, custom object and newer attributes). Use this documentation page as reference:

        http://docs.oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/facelets/f/selectItems.html

        • itemDescription can be ignored, as it seems to be meant for use in developer tools.
        Show
        Arturo Zambrano added a comment - r45036: added complete processing of the f:selectItems tag, in order to support non-SelectItem lists and arrays as well as newer attributes. Testing notes: Please create test cases for everything that's not already covered for testing the use of f:selectItems in ace:simpleSelectOneMenu (String array values, custom object and newer attributes). Use this documentation page as reference: http://docs.oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/facelets/f/selectItems.html itemDescription can be ignored, as it seems to be meant for use in developer tools.
        Hide
        Arturo Zambrano added a comment - - edited

        Closing issue again.

        That's just the way things work with non-custom objects. If you replace the ace:simpleSelectOneMenu tags for the standard h:selectOneMenu or h:selectOneRadio, you'll get the extact same results. These newer attributes are only used when the value is a custom object (i.e. a POJO that follows the JavaBeans naming conventions), as mentioned in the API documentation for the value attribute in f:selectItems:

        http://docs.oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/jsp/f/selectItems.html

        It seems that the var will only be set up when using a custom object. I tested this by modifying the test app. In the case of Test 2, the objects are SelectItems, and the component will use the values in those objects and not what's specified in the tag. In the test app bean, they are only defined with the value (e.g. new SelectItem("British Columbia")), but if you define other properties for these SelectItem's in the bean (e.g. new SelectItem("British Columbia", "BC label")), they will be used where they belong. Likewise, in the case of the HashMap, the actual values are plain Map entries, so there are no other properties to specify. The keys are used as labels and the objects they map to are used as the values.

        So, as long as the component is rendered successfully using Maps or Arrays, the tests pass.

        Show
        Arturo Zambrano added a comment - - edited Closing issue again. That's just the way things work with non-custom objects. If you replace the ace:simpleSelectOneMenu tags for the standard h:selectOneMenu or h:selectOneRadio, you'll get the extact same results. These newer attributes are only used when the value is a custom object (i.e. a POJO that follows the JavaBeans naming conventions), as mentioned in the API documentation for the value attribute in f:selectItems: http://docs.oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/jsp/f/selectItems.html It seems that the var will only be set up when using a custom object. I tested this by modifying the test app. In the case of Test 2, the objects are SelectItems, and the component will use the values in those objects and not what's specified in the tag. In the test app bean, they are only defined with the value (e.g. new SelectItem("British Columbia")), but if you define other properties for these SelectItem's in the bean (e.g. new SelectItem("British Columbia", "BC label")), they will be used where they belong. Likewise, in the case of the HashMap, the actual values are plain Map entries, so there are no other properties to specify. The keys are used as labels and the objects they map to are used as the values. So, as long as the component is rendered successfully using Maps or Arrays, the tests pass.
        Hide
        Liana Munroe added a comment -

        Verified ICEfaces 4 trunk r45261, Tomcat 7, IE 11, FF 34, Chrome 43. QA Test application has been updated accordingly.

        Show
        Liana Munroe added a comment - Verified ICEfaces 4 trunk r45261, Tomcat 7, IE 11, FF 34, Chrome 43. QA Test application has been updated accordingly.

          People

          • Assignee:
            Arturo Zambrano
            Reporter:
            Carlo Guglielmin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: