I’ve got a problem, concerning the “rendered” attribute of a h:outputStylesheet inside my composite component.
<h:outputStylesheet rendered="#{cc.attrs.value == 'somevalue'}" library="css" name="mainDark.css" target="head" />
does not work, even if the EL evaluates to ‘true’. Whereas
<h:outputText rendered="#{cc.attrs.value == 'somevalue'}" value="rendered = true" style="color: red;" />
is getting properly rendered/not rendered.
While this is already quite confusing, it gets even worse:
- if I replace the EL by just ‘true’ or ‘false’, the attribute works as intended.
- if I replace the EL by some other evaluation it works too. For example #{someBean.somevalue == ‘somevalue’} or just #{1 > 0}
Am I missing something, or might this just be some weird bug?
I’m running on Tomcat v7.0 and JSF2.0
Ok,
I think i found, why this is happening:
Instead of evaluating the EL, before passing it into the “rendered” attribute, the complete EL is passed through.
As the component outputSytylesheet does not know of the cc.attrs it allways evaluates it to false.
So
or
works, because it can be evaluated. Whereas
will allway be evaluated ‘false’ inside the component.
If anyone else experiences this “bug”, this is what i found the most convenient “solution”:
Should anyone know of a proper solution to this issue, please feel free to further respond 🙂
Best regards, Christian
EDIT: It also could be, because the css is rendered outside of the composite component, and therefore cannot evaluate the cc.attrs.