【问题标题】:jsf 2.0 - Pass an outcome as string into a composite componentjsf 2.0 - 将结果作为字符串传递给复合组件
【发布时间】:2011-08-01 17:37:16
【问题描述】:

我正在使用 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>

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

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

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

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

谢谢

【问题讨论】:

    标签: parameters jsf-2 composite-component commandlink


    【解决方案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>
    

    【讨论】:

    • 谢谢!我试过这种方法,但没有 "form:",这就是它不起作用的原因。
    猜你喜欢
    • 1970-01-01
    • 2011-06-02
    • 2020-01-18
    • 2018-06-05
    • 1970-01-01
    • 2011-05-21
    • 1970-01-01
    • 2016-01-22
    • 2014-05-28
    相关资源
    最近更新 更多