Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.8
-
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.
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.
Should compare our behavior to standard h: comp. Might be nice to convert nulls to "" to avoid this.