问题描述
我需要创建包含两个h:commandLinks的复合组件。我想从客户端代码传递f:setPropertyActionListeners应用于两个commandLinks。这有可能吗?我尝试使用cc:insertChildren,但未触发适当的设置器。
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}"/>
和我的组件:
<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>
我需要将动作监听器应用于这两个链接(进入ui:insert)
i need to apply actionlisteners to both links ( into ui:insert)
推荐答案
您需要声明 < cc:actionSource>
中,在名称
中带有事件名称(例如 actionEvent
),这对于您完全是任意的选择)以及这些命令的客户端ID链接在目标
中的空格中。
<cc:interface>
<cc:actionSource name="actionEvent" targets="textLink imgLink" />
</cc:interface>
Then you can use in the client:
<f:setPropertyActionListener for="actionEvent" ... />
别忘了删除< ui:insert>
。确实,这绝对不是正确的方法。
Don't forget to remove <ui:insert>
. This is indeed definitely not the right way.
这篇关于setPropertyActionListeners到复合组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!