Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Primefaces p:commandButton渲染属性不使用ajax更新_Primefaces_Jsf 2_Jsf 2.2 - Fatal编程技术网

Primefaces p:commandButton渲染属性不使用ajax更新

Primefaces p:commandButton渲染属性不使用ajax更新,primefaces,jsf-2,jsf-2.2,Primefaces,Jsf 2,Jsf 2.2,我从中得到: 只能使用ajax更新始终呈现的组件,即。 当它没有渲染属性时 但是我尝试了这段代码,ajax更新对我不起作用,我需要刷新浏览器以查看更改的按钮。我做错了什么 <p:outputPanel id="buttonArea"> <p:panel styleClass="button-area" rendered="#{user != null and loginManager.profile.id != userPage.profil

我从中得到:

只能使用ajax更新始终呈现的组件,即。 当它没有渲染属性时

但是我尝试了这段代码,ajax更新对我不起作用,我需要刷新浏览器以查看更改的按钮。我做错了什么

<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时尝试了带冒号和不带冒号,我尝试了碎片…

您的命令按钮需要自己的ID。更新它们而不是面板。

如果我按照答案的建议进行操作,它怎么可能是重复的?我引用了父组件是的,调用了操作,更新了数据库,如果我刷新浏览器,更改是可见的。控制台中没有任何内容。请创建一个控制台。您尝试过这个吗?不能直接使用动态渲染属性更新元素。至少不能从“隐藏”到“可见”,否则会起作用,或者当元素保持可见时