Pass method expression attribute through to nested composite component

試著忘記壹切 提交于 2019-12-11 11:15:00

问题


I have composite component DocumentSelector, which contains another composite component 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>

I need to pass method #{cc.showSelector} to composite component modalWindow from faces component DocumentSelector. But I have PropertyNotFoundException because ElResolver associate #{cc} with modalWindow component instead of DocumentSelector

modalWindow component:

<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> 

I use Java EE 7, JSF 2.2, WildFly 8.2.0


回答1:


Use <cc:attribute targets> to basically move the attribute to the specified component and use if necessary <cc:attribute targetAttributeName> to rename it.

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

Don't forget to remove the showListener="#{cc.showSelector}".



来源:https://stackoverflow.com/questions/29017273/pass-method-expression-attribute-through-to-nested-composite-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!