【问题标题】:Pass method expression attribute through to nested composite component将方法表达式属性传递给嵌套的复合组件
【发布时间】:2015-05-15 01:15:00
【问题描述】:

我有复合组件DocumentSelector,其中包含另一个复合组件modalWindow。

<cc:interface componentType="selector.DocumentSelector">
     <cc:attribute name="showSelector"
              method-signature="void listener(java.util.List)"/>
</cc:interface>

<cc:implementation>

    <div id="#{cc.clientId}">
        <ccs:modalWindow id="modal_window" showListener="#{cc.showSelector}"
                     mode="ajax">

        </ccs:modalWindow>
    </div>
</cc:implementation>

我需要将方法 #{cc.showSelector} 从 faces 组件 DocumentSelector 传递给复合组件 modalWindow。但我有PropertyNotFoundException 因为ElResolver 关联#{cc} 与modalWindow 组件而不是DocumentSelector

modalWindow 组件:

<cc:interface componentType="statistics.ModalWindow">
    <cc:attribute name="showListener" method-signature="void show()"/>
    <cc:attribute name="hideListener" method-signature="void hide()"/>
</cc:interface>
<cc:implementation>
</cc:implementation> 

我使用 Java EE 7、JSF 2.2、WildFly 8.2.0

【问题讨论】:

    标签: jsf jsf-2 el composite-component


    【解决方案1】:

    使用&lt;cc:attribute targets&gt; 基本上将属性移动到指定的组件,并在必要时使用&lt;cc:attribute targetAttributeName&gt; 对其进行重命名。

    <cc:attribute ... targets="modal_window" targetAttributeName="showListener" />
    

    不要忘记删除showListener="#{cc.showSelector}"。

    【讨论】:

    • 我尝试使用&lt;cc:attribute targets&gt;,但它不适用于我的复合组件。 getAttributes().get("showListener")返回null。
    • 它不是一个值表达式。这是一个方法表达式。
    猜你喜欢
    • 1970-01-01
    • 2012-03-01
    • 1970-01-01
    • 2016-10-22
    • 2011-09-15
    • 2011-06-02
    • 2019-04-08
    • 2012-12-25
    • 1970-01-01
    相关资源
    最近更新 更多