ICEfaces
  1. ICEfaces
  2. ICE-4545

selectItem will not render if label is null

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.2-RC1, 1.8.2
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      All
    • Workaround Exists:
      Yes
    • Workaround Description:
      Ensure SelectItems are constructed with non null values.

      Description

      If the SelectItem constructer's label is null (SelectItem(java.lang.Object value, java.lang.String label)), ICEfaces will fail to render the SelectItem and will throw an exception. Here is the code required to reproduce the issue:

      public class BackingBean {

      private String selectedItem;

      private SelectItem[] items = new SelectItem[]{
      new SelectItem("value1","label1"),
      new SelectItem("value2","label2"),
      new SelectItem("value3",null),
      new SelectItem("value4","label4")
      };
      ........

      main.jspx

      <ice:selectOneMenu id="SlctCompTyp"
      partialSubmit="true">
      <f:selectItems id="SlctcompTypeItms"
      value="#{backingBean.items}"/>
      </ice:selectOneMenu>
      ........

      will cause the following exception to be thrown:

      16:21:06,926 WARN [lifecycle] executePhase(RENDER_RESPONSE 6,com.icesoft.faces.context.BridgeFacesContext@1e212d0) threw exception
      java.lang.NullPointerException
      at java.io.Writer.write(Unknown Source)
      at com.icesoft.faces.util.DOMUtils.printNode(DOMUtils.java:182)
      at com.icesoft.faces.util.DOMUtils.printNode(DOMUtils.java:168)
      at com.icesoft.faces.util.DOMUtils.printNode(DOMUtils.java:168)
      .....

      The workaround would of course be to have non null values. It would be nice to not throw such a nasty exception and instead handle it a bit more gracefully.

        Activity

        Hide
        Ken Fyten added a comment -

        Should compare our behavior to standard h: comp. Might be nice to convert nulls to "" to avoid this.

        Show
        Ken Fyten added a comment - Should compare our behavior to standard h: comp. Might be nice to convert nulls to "" to avoid this.
        Hide
        yip.ng added a comment -

        Can't reproduce. See screenshot. If I used a null label, the label would show up as "null", but there would be no runtime exception. Will try to change the null to empty string anyway.

        Show
        yip.ng added a comment - Can't reproduce. See screenshot. If I used a null label, the label would show up as "null", but there would be no runtime exception. Will try to change the null to empty string anyway.
        Hide
        Ken Fyten added a comment -

        What does the stock h: component do with a null entry?

        Show
        Ken Fyten added a comment - What does the stock h: component do with a null entry?
        Hide
        yip.ng added a comment -

        1.1_02 (24 April 2006):

        writer.writeText(curItem.getLabel(), "label");

        1.2 (May 2006):

        if (curItem.isEscape())

        { writer.writeText(curItem.getLabel(), "label"); }

        else

        { writer.write(curItem.getLabel()); }

        1.2_12 (16 Jan 2009):

        if (curItem.isEscape()) {
        String label = curItem.getLabel();
        if (label == null) { label = valueString; }
        writer.writeText(label, component, "label");
        } else { writer.write(curItem.getLabel()); }
        Show
        yip.ng added a comment - 1.1_02 (24 April 2006): writer.writeText(curItem.getLabel(), "label"); 1.2 (May 2006): if (curItem.isEscape()) { writer.writeText(curItem.getLabel(), "label"); } else { writer.write(curItem.getLabel()); } 1.2_12 (16 Jan 2009): if (curItem.isEscape()) { String label = curItem.getLabel(); if (label == null) { label = valueString; } writer.writeText(label, component, "label"); } else { writer.write(curItem.getLabel()); }
        Hide
        yip.ng added a comment -

        Changed to use the value of a select item (i.e. value of <option>) as label if label is null. (There is no isEscape() in JSF 1.1.)

        Show
        yip.ng added a comment - Changed to use the value of a select item (i.e. value of <option>) as label if label is null. (There is no isEscape() in JSF 1.1.)

          People

          • Assignee:
            yip.ng
            Reporter:
            Tyler Johnson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: