Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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
JSF2复合组件,将属性传递给支持bean_Jsf_Jsf 2_El - Fatal编程技术网

JSF2复合组件,将属性传递给支持bean

JSF2复合组件,将属性传递给支持bean,jsf,jsf-2,el,Jsf,Jsf 2,El,我被简单的JSF2问题困住了: XHTML: <xvf:simpleOut identifier="12345"/> 复合组件应该将“12345”传递给支持bean并执行一些输出: <composite:interface> <composite:attribute name="identifier" required="true" type="java.lang.String"/> </composite:interface> &

我被简单的JSF2问题困住了:

XHTML:

<xvf:simpleOut identifier="12345"/>

复合组件应该将“12345”传递给支持bean并执行一些输出:

<composite:interface>
    <composite:attribute name="identifier" required="true" type="java.lang.String"/>
</composite:interface>

<composite:implementation>
    <!--@elvariable id="arg" type="java.lang.String"-->
    <ui:param name="arg" value="#{cc.attrs.identifier}"/>
    <h:outputText value="#{myBean.getTestOutput('???????')}"/>
</composite:implementation>

如何将
标识符
值“12345”传递给bean的
getTestOutput(String arg)
方法?

您根本不需要
标记。这应该起作用:

<h:outputText value="#{myBean.getTestOutput(cc.attrs.identifier)}"/>

但是通过接口传递myBean而不是直接引用它可能是一个好主意,因为这样可以使复合组件可重用。

您根本不需要
标记。这应该起作用:

<h:outputText value="#{myBean.getTestOutput(cc.attrs.identifier)}"/>


但是通过接口传递
myBean
也可能是一个好主意,而不是直接引用它,因为这将使复合组件可重用。

谢谢,你救了我一天!对我来说,cc.attrs.*与elvariables不同,它可以传递给支持bean,这是一件新鲜事。@Osw:我不知道你所说的“与elvariables不同”是什么意思。如果一个变量可以由EL解析器解析,那么它可以传递给一个方法——如果您的JSF容器支持EL表达式中的方法参数,而EL表达式仅在EL 2.2中可用。您是对的。我的错误是我使用了嵌套的el表达式,比如“#{myBean.getTestOutput(#{arg})”。再次感谢。谢谢,你救了我一天!对我来说,cc.attrs.*与elvariables不同,它可以传递给支持bean,这是一件新鲜事。@Osw:我不知道你所说的“与elvariables不同”是什么意思。如果一个变量可以由EL解析器解析,那么它可以传递给一个方法——如果您的JSF容器支持EL表达式中的方法参数,而EL表达式仅在EL 2.2中可用。您是对的。我的错误是我使用了嵌套的el表达式,比如“#{myBean.getTestOutput(#{arg})”。再次感谢。