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

        Tyler Johnson created issue -
        Tyler Johnson made changes -
        Field Original Value New Value
        Salesforce Case [500700000080czp, 50070000007BmrT]
        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.
        Ken Fyten made changes -
        Fix Version/s 1.8.2 [ 10190 ]
        Assignee Priority P3
        Assignee Mark Collette [ mark.collette ]
        Ken Fyten made changes -
        Assignee Mark Collette [ mark.collette ] Yip Ng [ yip.ng ]
        yip.ng made changes -
        Attachment ScreenHunter_04.jpg [ 11816 ]
        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?
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #19022 Wed Jul 01 15:43:24 MDT 2009 yip.ng ICE-4545
        Changed to use the value of a select item as label if the label is null.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/renderkit/dom_html_basic/MenuRenderer.java
        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.)
        yip.ng made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        yip.ng made changes -
        Attachment ScreenHunter_05.jpg [ 11817 ]
        Ken Fyten made changes -
        Fix Version/s 1.8.2-RC1 [ 10210 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Priority P3

          People

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

            Dates

            • Created:
              Updated:
              Resolved: