You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2014/11/19 14:41:20 UTC

svn commit: r1640548 - /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeListboxRenderer.java

Author: lofwyr
Date: Wed Nov 19 13:41:20 2014
New Revision: 1640548

URL: http://svn.apache.org/r1640548
Log:
fixing NPE when there is no UITreeSelect

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeListboxRenderer.java

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeListboxRenderer.java?rev=1640548&r1=1640547&r2=1640548&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeListboxRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TreeListboxRenderer.java Wed Nov 19 13:41:20 2014
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.component.UITreeLabel;
 import org.apache.myfaces.tobago.component.UITreeNode;
 import org.apache.myfaces.tobago.component.UITreeSelect;
 import org.apache.myfaces.tobago.internal.component.AbstractUITree;
@@ -174,11 +175,21 @@ public class TreeListboxRenderer extends
     writer.writeAttribute(HtmlAttributes.SIZE, 9); // must be > 1, but the real size comes from the layout
 //    writer.writeAttribute(HtmlAttributes.MULTIPLE, siblingMode);
 
-    final UITreeSelect label = ComponentUtils.findDescendant(tree, UITreeSelect.class);
-    final Object labelValue = label.getLabel();
+    final UITreeSelect select = ComponentUtils.findDescendant(tree, UITreeSelect.class);
+    final String labelValue;
+    if (select != null) {
+      labelValue = select.getLabel();
+    } else {
+      final UITreeLabel label = ComponentUtils.findDescendant(tree, UITreeLabel.class);
+      if (label != null) {
+        labelValue = label.getLabel();
+      } else {
+        labelValue = null;
+      }
+    }
     if (labelValue != null) {
       writer.startElement(HtmlElements.OPTGROUP, tree);
-      writer.writeAttribute(HtmlAttributes.LABEL, labelValue.toString(), true);
+      writer.writeAttribute(HtmlAttributes.LABEL, labelValue, true);
       writer.endElement(HtmlElements.OPTGROUP);
     }