nullpointer for param inside commandlink

The problem started when I added this param to a commandlink like in the code below:

<f:param name="elementNbr"
value="#{item.elementId}" />

With Glassfish version 9.1_01 (build b09d-fcs) I then got this error:

at com.sun.faces.renderkit.RenderKitUtils.getCommandLinkOnClickScript(
at com.sun.faces.renderkit.html_basic.CommandLinkRenderer.getOnClickScript(
at com.sun.faces.renderkit.html_basic.CommandLinkRenderer.renderAsActive(
at com.sun.faces.renderkit.html_basic.CommandLinkRenderer.encodeBegin(

After some investigation I got to this issue stating that you would get this error when the given param value is null. Good news is that it’s solved in following versions of glassfish. I quote:

The following will blow up:

The reason is that, while HtmlBasicRenderer.getParamList(UIComponent)
acknowledges that the parameter value may be null, and thus creates a
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.Param instance with a null
value if the parameter’s value was null, the code in
RenderKitUtils.getCommandLinkOnClickScript dereferences the param.value property
without checking whether it is null:

for (Param param : params) {         
sb.append("'", "\\\'"));
sb.append(param.value.replace("'", "\\\'"));

Resulting in an NPE.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please reload

Please Wait