Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSF 2复合组件EL类型转换错误_Jsf_El_Composite Component - Fatal编程技术网

JSF 2复合组件EL类型转换错误

JSF 2复合组件EL类型转换错误,jsf,el,composite-component,Jsf,El,Composite Component,我有一个JSF复合组件,在接口部分有一个EL表达式,下面是代码片段 <cc:interface> <cc:attribute name="label" type="java.lang.String"/> <cc:attribute name="labelRendered" default="#{cc.attrs.label ne null}"/> </cc:interface> <cc:implementation>

我有一个JSF复合组件,在接口部分有一个EL表达式,下面是代码片段

<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>
我使用的是JSF2.0.4,EL2.1,WAS7

{cc.attrs}
仅在
中可用

我建议重写如下:

<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>

...

我会试试你的建议。非常感谢,:)还有一件事,我确实尝试在Glassfish 3上运行了上面的代码,它似乎运行得很完美,我遗漏了什么吗?配置还是一个罐子?再次感谢。
<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>