javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1687

Renderers for UISelectMany don't support value attribute of type Map

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Duplicate
    • Affects Version/s: 1.2_14
    • Fix Version/s: None
    • Component/s: renderkit
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,687
    • Status Whiteboard:
      Hide

      size_medium importance_large

      Show
      size_medium importance_large

      Description

      https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=772

      The spec says the value attribute for UISelectMany may be:

      Single instance of SelectItem - This instance is added to the set of available options for the parent
      tag.
      Array of SelectItem - This set of instances is added to the set of available options for the parent
      component, in ascending subscript order.
      Collection of SelectItem - This set of instances is added to the set of available options for the
      parent component, in the order provided by an iterator over them.
      Map - The keys of this object (once converted to Strings) are assumed to be labels, and the values
      of this object (once converted to Strings) are assumed to be values, of SelectItem instances that will
      be constructed dynamically and added to the set of available options for the parent component, in
      the order provided by an iterator over the keys.
      -----------

      Indeed the RenderKit doc for SelectManyListBox says:

      If the result is a Map, create a SelectItem bean for each entry in the Map using the key as the label,
      the value as the value, and null as the description.

      ------------------------

      Unfortunately, the implementation doesn't seem to support this.

        Issue Links

          Activity

          Hide
          Ed Burns added a comment -

          <h:selectManyListbox value="#

          {selectItemsMapBean.choices}

          " size="2">
          <f:selectItems value="#

          {selectItemsMapBean.selectItemsMapItemCollection}

          "
          var="n"
          itemValue="#

          {n.value}

          "
          itemLabel="#

          {n.label}

          " />
          </h:selectManyListbox>

          <h:commandButton value="submit" />

          @ManagedBean
          @RequestScoped
          public class SelectItemsMapBean {

          private Map<String, String> choices;
          public SelectItemsMapBean()

          { items = new ArrayList<SelectItemsMapItem>(); items.add(new SelectItemsMapItem("label01", "value01", "description01")); items.add(new SelectItemsMapItem("label02", "value02", "description02")); items.add(new SelectItemsMapItem("label03", "value03", "description03")); items.add(new SelectItemsMapItem("label04", "value04", "description04")); choices = new HashMap<String, String>(); choices.put(items.get(0).getLabel(), items.get(0).getValue()); choices.put(items.get(3).getLabel(), items.get(3).getValue()); }

          public Map<String, String> getChoices()

          { return choices; }

          private List<SelectItemsMapItem> items;

          public Collection<SelectItemsMapItem> getSelectItemsMapItemCollection()

          { return items; }

          }

          public class SelectItemsMapItem {

          public SelectItemsMapItem(String label, String value, String description)

          { this.label = label; this.value = value; this.description = description; }

          protected String label;

          public String getLabel()

          { return label; }

          public void setLabel(String label)

          { this.label = label; }

          protected String value;

          public String getValue()

          { return value; }

          public void setValue(String value)

          { this.value = value; }

          protected String description;

          public String getDescription()

          { return description; }

          public void setDescription(String description)

          { this.description = description; }

          }

          Show
          Ed Burns added a comment - <h:selectManyListbox value="# {selectItemsMapBean.choices} " size="2"> <f:selectItems value="# {selectItemsMapBean.selectItemsMapItemCollection} " var="n" itemValue="# {n.value} " itemLabel="# {n.label} " /> </h:selectManyListbox> <h:commandButton value="submit" /> @ManagedBean @RequestScoped public class SelectItemsMapBean { private Map<String, String> choices; public SelectItemsMapBean() { items = new ArrayList<SelectItemsMapItem>(); items.add(new SelectItemsMapItem("label01", "value01", "description01")); items.add(new SelectItemsMapItem("label02", "value02", "description02")); items.add(new SelectItemsMapItem("label03", "value03", "description03")); items.add(new SelectItemsMapItem("label04", "value04", "description04")); choices = new HashMap<String, String>(); choices.put(items.get(0).getLabel(), items.get(0).getValue()); choices.put(items.get(3).getLabel(), items.get(3).getValue()); } public Map<String, String> getChoices() { return choices; } private List<SelectItemsMapItem> items; public Collection<SelectItemsMapItem> getSelectItemsMapItemCollection() { return items; } } public class SelectItemsMapItem { public SelectItemsMapItem(String label, String value, String description) { this.label = label; this.value = value; this.description = description; } protected String label; public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } protected String value; public String getValue() { return value; } public void setValue(String value) { this.value = value; } protected String description; public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } }
          Hide
          Ed Burns added a comment -

          Created an attachment (id=1163)
          testcase files

          Show
          Ed Burns added a comment - Created an attachment (id=1163) testcase files
          Hide
          Manfred Riem added a comment -

          Closing this one as a duplicate of spec issue 772

          Show
          Manfred Riem added a comment - Closing this one as a duplicate of spec issue 772

            People

            • Assignee:
              Manfred Riem
              Reporter:
              Ed Burns
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: