有条件地调用rich:popup面板 [英] Conditional invocation of rich:popup panel
问题描述
大家好,我想在条件表达式中打开rich:popupPanel,实际上我正在尝试的是这样的事情:
Hello Everyone I would like to open a rich:popupPanel inside a conditional expression, actually what I'm trying is something like this:
onclick="#{searchBackingBean.showLoginPanel==true ? #{rich:component('loginPopup')}.show();':''}"
但是,我遇到与EL有关的错误时,如何正确编写呢? 非常感谢.
However I'm getting errors related to EL, how should I write this correctly?. Thanks a lot.
推荐答案
您不得嵌套EL表达式.我建议按照以下方式重写表达式,以便将条件委托给JavaScript:
You may not nest EL expressions. I suggest to rewrite the expression as follows so that the condition is delegated to JavaScript:
onclick="if (#{searchBackingBean.showLoginPanel}) #{rich:component('loginPopup')}.show();"
(请注意,我删除了多余的== true
比较,因为这没有意义,因为该方法已经返回/打印了布尔值)
(please note that I removed the superfluous == true
comparison because this makes no sense as the method returns/prints a boolean value already)
请注意,这仅在<rich:xxx>
和<a4j:xxx>
组件中有效,因为它们增强了on*
属性以重新评估回发时的EL表达式.标准的JSF <h:xxx>
组件无法做到这一点.您需要使用rendered
属性来解决该问题:
Note that this only works in <rich:xxx>
and <a4j:xxx>
components as they have enhanced the on*
attributes to re-evaluate the EL expression on postbacks. The standard JSF <h:xxx>
components doesn't do that. You'd need to workaround it with the rendered
attribute:
<h:commandButton>
<f:ajax render="script" />
</h:commandButton>
<h:panelGroup id="script">
<h:panelGroup rendered="#{searchBackingBean.showLoginPanel}">
<script>#{rich:component('loginPopup')}.show();</script>
</h:panelGroup>
</h:panelGroup>
这篇关于有条件地调用rich:popup面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!