JSF 中的多个 AJAX 侦听器
我试图在事件 valueChange 之后触发两个侦听器,如下所示:
<h:selectOneListbox id="premiumLevel"
value="#{createPremiumUserDTO.premiumLevel}" size="1"
rendered="#{createPremiumUser.step >= 2}">
<f:selectItem itemValue="9" itemLabel="Partner (9)" />
<f:selectItem itemValue="10" itemLabel="Musiclabel (10)" />
<f:selectItem itemValue="11" itemLabel="Series (11)" />
<f:selectItem itemValue="12" itemLabel="Filme (12)" />
<f:selectItem itemValue="13" itemLabel="Syndication (13)" />
<f:ajax listener="#{createPremiumUser.getBusinessRuleSets(createPremiumUserDTO.premiumLevel)}"
render="businessRule" />
<f:ajax listener="#{createPremiumUser.getEncodingParameters(createPremiumUserDTO.premiumLevel, createPremiumUserDTO.defaultBusinessRuleSetId, createPremiumUserDTO.defaultEncodingParameter)}"
render="encodingParameter" />
</h:selectOneListbox>
但我注意到,第二个 f:ajax 侦听器被完全忽略。我生成的 HTML 仅引用第一个。如何向同一元素添加第二个侦听器?无论如何有可能吗?
提前致谢! Rodrigo——
更新:
找到了解决方案,感谢 Bachboss 的评论。看来我的实现从一开始就是错误的。由于我的目标元素(businessRule 和encodingParameter)已经调用这些相应的侦听器,因此无需在 f:ajax 标记下调用它。所以......
<f:ajax render="businessRule encodingParameter" />
就足够了,并强制两个元素重新渲染,并且它们将调用各自的方法。
非常感谢,巴赫老板! 罗德里戈
I'm trying to trigger two listeners after an event valueChange, like that:
<h:selectOneListbox id="premiumLevel"
value="#{createPremiumUserDTO.premiumLevel}" size="1"
rendered="#{createPremiumUser.step >= 2}">
<f:selectItem itemValue="9" itemLabel="Partner (9)" />
<f:selectItem itemValue="10" itemLabel="Musiclabel (10)" />
<f:selectItem itemValue="11" itemLabel="Series (11)" />
<f:selectItem itemValue="12" itemLabel="Filme (12)" />
<f:selectItem itemValue="13" itemLabel="Syndication (13)" />
<f:ajax listener="#{createPremiumUser.getBusinessRuleSets(createPremiumUserDTO.premiumLevel)}"
render="businessRule" />
<f:ajax listener="#{createPremiumUser.getEncodingParameters(createPremiumUserDTO.premiumLevel, createPremiumUserDTO.defaultBusinessRuleSetId, createPremiumUserDTO.defaultEncodingParameter)}"
render="encodingParameter" />
</h:selectOneListbox>
But i've noticed, the second f:ajax listener is completely ignored. My generated HTML only references the first one. How can i add a second listener to the same element? Is it possible in anyway?
Thanks in advance!
Rodrigo
-- UPDATE:
Found a solution, thanks to Bachboss' comment. It seems like my implementation was wrong from the beginning. As my target elements (businessRule and encodingParameter) already call these respective listeners, there is no need to call it under the f:ajax tag. So...
<f:ajax render="businessRule encodingParameter" />
... is enough, and forces both elements to re-render, and they will call the respective methods.
Thanks a lot, Bachboss!
Rodrigo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论