JSF - Target Unreachable, identifier '' resolved to null - workaround

495 Views Asked by At

Every time I don't set value to binding attribute (which is located in facelet) I get the exception;

jsf Target Unreachable, identifier '' resolved to null

The facelet usage both ways :

<my:tag ... tagBingingBean="#{myBean}"/>
<my:tag ... /> causes NPE

So my question is...

is there a way to catch the NPE and ignore it in case binding has no value?

Thanks

1

There are 1 best solutions below

0
cbhogf On BEST ANSWER

Well, I guess maybe I could figure out how to use EL JSF 2.0 to really work it around using http://java.sun.com/jstl/core...

<composition ...>
<c:if test="#{not empty tagBingingBean}">
  <h:panelGroup ... binding="#{tagBingingBean}">...</h:panelGroup>
</c:if>

<c:if test="#{empty tagBingingBean}">
  ...
</c:if>

</composition>

I am not sure it is a final solution but, yes, it helps to work around the NPE issue in case of null binding attribute value