Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12661

rich:tooltip causes NPE with null value

    XMLWordPrintable

    Details

    • Workaround Description:
      Hide

      don't render tooltip with null value:
      rendered="#

      {yourValue != null}

      "

      Show
      don't render tooltip with null value: rendered="# {yourValue != null} "

      Description

      rich:tooltip with null value causes NullPointerException:

      Caused by: java.lang.NullPointerException
              at org.richfaces.renderkit.html.TooltipRenderer.encodeContentBegin(TooltipRenderer.java:135)
              at org.richfaces.renderkit.html.TooltipRenderer.doEncodeBegin(TooltipRenderer.java:127)
              at org.richfaces.renderkit.RendererBase.encodeBegin(RendererBase.java:115)
              at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:585)
              at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:515)
              at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
      ...........
      

      Proposed solution:

      org.richfaces.renderkit.html.TooltipRenderer
      	130    private void encodeContentBegin(ResponseWriter writer, FacesContext context, AbstractTooltip tooltip) throws IOException {
      	131        writer.startElement(getMarkupElement(tooltip), tooltip);
      	132        writer.writeAttribute(ID_ATTRIBUTE, tooltip.getClientId(context) + ":content", null);
      	133        writer.writeAttribute(CLASS_ATTRIBUTE, "rf-tt-cnt", null);
      	134        if (tooltip.getChildCount() == 0) {
      -	135            writer.write(tooltip.getValue().toString());
      +	135            writer.write(tooltip.getValue() != null ? tooltip.getValue().toString() : "");
      	136        }
      	137    }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                michpetrov Michal Petrov
                Reporter:
                rmaknys Raimundas Maknys
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: