【发布时间】:2017-10-16 00:03:00
【问题描述】:
来自this answer 我知道了:
您只能对始终呈现的组件进行 ajax 更新(即 当它没有渲染属性时)。
但我尝试了这段代码,但 ajax-update 对我不起作用,我需要刷新浏览器才能看到更改后的按钮。我做错了什么?
<p:outputPanel id="buttonArea">
<p:panel styleClass="button-area"
rendered="#{user != null and loginManager.profile.id != userPage.profile.id}">
<h:form>
<p:commandButton styleClass="button-flat" action="#{userPage.followUser}"
value="Follow" rendered="#{!userPage.followed}" update="buttonArea"/>
<p:commandButton styleClass="button-flat" action="#{userPage.unfollowUser}"
value="Unfollow" rendered="#{userPage.followed}" update="buttonArea"/>
</h:form>
</p:panel>
</p:outputPanel>
编辑:
我尝试了可能重复的问题的解决方案,但它对我也不起作用,我做错了,那里没有解释,我尝试使用 ajax 标签,html 中的 id 正是“buttonArea”但是当我引用 id 时,我什至尝试使用冒号和不使用冒号,我尝试使用片段...
【问题讨论】:
-
如果我按照答案的建议去做,它怎么可能是重复的?,我引用了一个父组件
-
是的,动作被调用,数据库被更新,如果我刷新浏览器,变化是可见的。控制台中什么都没有。
标签: primefaces jsf-2 jsf-2.2