JSF 2 Composite:ActionSource在ui:repeat中公开commandButtons [英] JSF 2 composite:actionSource exposing commandButtons in ui:repeat
问题描述
在我的复合组件中,我有一个ui:repeat,其中除了其他静态内容外,还具有一个命令按钮,如下所示:
In my composite component, I have a ui:repeat that has, among other static things, a command button, like this:
<ui:repeat var="article" value="#{cc.attrs.articleList}">
<strong>Aricle: #{article}</strong>
<h:commandButton id="addToFavs" value="Subscribe" binding="..." type="..." >
<f:setPropertyActionListener value="#{article}" target="..." />
</h:commandButton >
</ui:repeat>
现在,我想在复合界面中公开此事件,以便在我的页面中,我可以附加事件侦听器并绑定f:ajax.
Now, I'd like to expose this event in the composite interface, so that in my page, I may attach event listeners and tie in f:ajax.
如果它不在ui:repeat之外(即仅存在一个这样的按钮),那将是非常容易的,就像这样:
Had it been outside of ui:repeat (i.e., there existed only one such button), that would have been quite easy, like this:
<composite:interface>
<composite:actionSource name="addToFavs" targets="#{cc.clientId}:addToFavs" />
<composite:clientBehavior name="ajax" default="true"
event="action" targets="#{cc.clientId}:addToFavs"/>
</composite:interface>
但是在这种情况下失败了,因为该ID没有一个组件( addToFavs ),而是一堆组件.您知道我应该如何在界面中显示这些按钮吗?
But that fails in this case, because there's no one component by that ID (addToFavs), but rather a bunch of them. Do you know how should I expose these buttons in the interface?
此致
Pradyumna
Pradyumna
推荐答案
以我的最佳猜测来更新此帖子,以防万一有人想知道我是否可以实现:
Updating this post with my best guess, just in case someone wants to know if I could achieve it:
不,我做不到.看来我们做不到.我们只能公开组件作者事先知道相对于复合组件的ID的组件.
No I couldn't do it. Looks like we can't do it. We can only expose components whose IDs relative to the composite component are known to the component author apriori.
这篇关于JSF 2 Composite:ActionSource在ui:repeat中公开commandButtons的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!