I don't understand why this piece of code is working:
<h:link value="Login" rendered="#{sessionBean.userInSessionBean == null}" />
and this piece of code is not working:
<a jsf:rendered="#{sessionBean.userInSessionBean == null}">Login</a>
I don't understand why this piece of code is working:
<h:link value="Login" rendered="#{sessionBean.userInSessionBean == null}" />
and this piece of code is not working:
<a jsf:rendered="#{sessionBean.userInSessionBean == null}">Login</a>
A HTML element will only become a passthrough element if following conditions are met:
jsf:xxxattribute fromhttp://xmlns.jcp.org/jsfnamespace.For the
<a>element an identifying attribute is necessary so JSF can decide whether to interpret it as<h:commandLink>,<h:outputLink>or<h:link>. Without an identifying attribute, JSF wouldn't have any idea what component you actually meant to use, so anyjsf:xxxattributes will be ignored. Thejsf:renderedis not sufficient as identifying attribute because it appears on every single JSF component, so JSF would still have no idea which one you meant.Given that you seem to intend to have a
<h:link>, then usejsf:outcomeas identifying attribute.A completely different alternative is to wrap plain HTML in an
<ui:fragment rendered>. See also How to conditionally render plain HTML elements like <div>s?