Josf 2 Composote EL Component Issue

I have a JSF Composite component that has an EL expression in the interface part, the code snippet below.

<cc:interface> <cc:attribute name="label" type="java.lang.String"/> <cc:attribute name="labelRendered" default="#{cc.attrs.label ne null}"/> </cc:interface> <cc:implementation> <h:outputText rendered="#{cc.attrs.labelRendered}" value="#{cc.attrs.label}"/> </cc:implementation> 

Now my problem is that "default =" # {cc.attrs.label ne null} "gives an error.

 java.lang.IllegalArgumentException: Cannot convert /resources/cc/label.xhtml @20,85 default="#{cc.attrs.label != null}" of type class com.sun.faces.facelets.el.TagValueExpression to class java.lang.Boolean 

I am using JSF 2.0.4, EL 2.1, WAS 7

+4
source share
1 answer

#{cc.attrs} is only available inside <cc:implementation> .

I would suggest rewriting it as follows:

 <cc:interface> <cc:attribute name="label" type="java.lang.String"/> <cc:attribute name="labelRendered" type="java.lang.Boolean" /> </cc:interface> <cc:implementation> <ui:param name="labelRendered" value="#{empty cc.attrs.labelRendered ? not empty cc.attrs.label : cc.attrs.labelRendered}" /> ... <h:outputText rendered="#{labelRendered}" value="#{cc.attrs.label}"/> </cc:implementation> 
+7
source

All Articles