1

我正在使用 jsf2 创建一个简单的复合组件,但由于一个愚蠢的问题而被卡住了。

我不知道如何将结果作为参数发送给组合,该参数将用作 commandLink 上的操作。

例子:

<!-- Usage -->
<my:comp myAction="myOutcome" />

<!-- Component -->
<composite:interface>
    <composite:attribute name="myAction" required="true" />
</composite:interface>

<composite:implementation>
    <h:form>
        <h:commandLink action="#{cc.attrs.myAction}" value="Go" />
    </h:form>
</composite:implementation>

<!-- Expected result -->
<h:form><h:commandLink action="myOutcome" value="Go" /></h:form>

我已阅读此主题,但没有成功。

我发现的唯一解决方案是使用托管 bean 作为重定向器:

<h:commandLink action="#{redirectorBean.go(cc.attrs.myMaction)}" value="Go" />.

有人可以通过更好(更简单)的解决方案帮助我实现这一目标吗?

谢谢

4

1 回答 1

1

属性名称必须action,并且您需要指定复合属性的targets属性,该属性引用相对的 commandlink 客户端 ID。

用法:

<my:comp action="myOutcome" />

复合组件:

<composite:interface>
    <composite:attribute name="action" targets="form:go" required="true" />
</composite:interface>

<composite:implementation>
    <h:form id="form">
        <h:commandLink id="go" value="Go" />
    </h:form>
</composite:implementation>
于 2011-08-01T17:59:24.127 回答