setPropertyActionListeners to composite component

故事扮演 提交于 2019-12-11 02:56:07

问题


I need to create composite component containing two h:commandLinks. And i want to pass f:setPropertyActionListeners from the client-code to be applied to both two commandLinks. Is this ever possible? I tried to use cc:insertChildren, but appropriate setters are not being fired.

<my:operationLink action="#{cc.attrs.bean.myAction}">
 <f:setPropertyActionListener for="<!-- whats here? -->" value="#{cc.attrs.someAttrOne}" target="#{cc.attrs.bean.someAttrTargetOne}"/>
 <f:setPropertyActionListener for="<!-- whats here? -->" value="#{cc.attrs.someAttrTwo}" target="#{cc.attrs.bean.someAttrTargetTwo}"/>

and my component:

<cc:implementation>
<h:commandLink id="textLink" value="myTextLink"><ui:insert/></h:commandLink>
<h:commandLink id="imgLink"><h:graphicImage url="/images/my.gif"/><ui:insert/></h:commandLink>

i need to apply actionlisteners to both links ( into ui:insert)


回答1:


You need to declare a <cc:actionSource> in the composite interface with the "event name" in name (e.g. actionEvent, this is fully arbitrary to your choice) and the client IDs of those command links space separated in the targets.

<cc:interface>
    <cc:actionSource name="actionEvent" targets="textLink imgLink" />
</cc:interface>

Then you can use in the client:

<f:setPropertyActionListener for="actionEvent" ... />

Don't forget to remove <ui:insert>. This is indeed definitely not the right way.



来源:https://stackoverflow.com/questions/20070422/setpropertyactionlisteners-to-composite-component

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