【发布时间】:2013-07-04 13:44:32
【问题描述】:
我对这两个命令按钮有问题:加入和离开。
如果我点击离开,我想隐藏加入,反之亦然。
当我将 ajax 设置为 false 时,没有问题(但所有页面都在刷新,我觉得这不是最佳的)。
但是,当 ajax 属性为 true 并进行特定更新时(参见代码中的注释),渲染效果很好,但新按钮似乎变得不活动。如果我点击它,什么也不会发生(好吧,似乎是 actionListener 触发器,但视图没有刷新,我必须手动刷新才能看到差异)
感谢阅读。
<h:form id="formWaitingList" rendered="#{connexion.connected}" >
<p:commandButton id="Join"
actionListener = "#{connexion.joinWaitingList()}"
rendered="#{!connexion.waiting}"
ajax="false"
<!-- ajax="true"
update="Join,Leave"-->
value="Join"/>
<p:commandButton id="Leave"
value="Leave"
ajax="false"
<!-- ajax="true"
udpate="Join,Leave"-->
rendered="#{connexion.waiting}"
actionListener ="#{connexion.leaveWaitingList()}" />
</h:form>
【问题讨论】:
-
你应该使用 update="@form" 因为
buttonswith render=false 不会出现在html生成的代码中,所以你不能直接更新它们。
标签: jsf primefaces updates renderer commandbutton