将方法表达式属性传递给嵌套复合组件

时间:2015-03-12 18:12:27

标签: jsf jsf-2 el composite-component

我有复合组件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}传递给面组件modalWindow的复合组件DocumentSelector。但我有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

1 个答案:

答案 0 :(得分:5)

使用<cc:attribute targets>基本上将属性移动到指定的组件,并在必要时使用<cc:attribute targetAttributeName>重命名。

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

别忘了删除showListener="#{cc.showSelector}"