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