jsfjsf-2elfaceletsbacking-beans

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


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


Solution

  • 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