p:commandButton更新在ui:include中不起作用 [英] p:commandButton update doesn't work in ui:include

查看:70
本文介绍了p:commandButton更新在ui:include中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过PPR更新页面的一部分. 这是我要更新的页面部分:

I want to update a part of a page by PPR. This is the part of page that i want to update:

 <h:panelGroup id="aggiungiAuto"
                  rendered="#{!autoBean.operazioneOk}">
        <ui:include src="../component/aggiungi_auto.xhtml"/>
 </h:panelGroup>

这是aggiungi_auto.xhtml中的commandButton

While this is the commandButton present in aggiungi_auto.xhtml

 <p:commandButton value="Submit"
                  update="growl aggiungiAuto aggiungiFoto"
                  actionListener="#{autoBean.insert}"/>

有什么想法吗?

推荐答案

JS/Ajax在客户端而不是服务器端工作. JSF在服务器端而不是客户端上工作.当您指示JSF不将组件呈现为HTML时,客户端将不存在任何内容,因此JS/Ajax将无法找到要刷新/更新的HTML元素.

JS/Ajax works on the client side, not on the server side. JSF works on the server side, not on the client side. When you instruct JSF to not render the component to HTML, then nothing will be present in the client side, so JS/Ajax will be unable to locate the HTML element to refresh/update.

您需要将其包装在另一个<h:panelGroup>中.

You need to wrap it in another <h:panelGroup>.

<h:panelGroup id="aggiungiAuto">
    <h:panelGroup rendered="#{!autoBean.operazioneOk}">
        <ui:include src="../component/aggiungi_auto.xhtml"/>
    </h:panelGroup>
</h:panelGroup>

这样,<span id="aggiuniAuto">总是 出现在客户端,因此JS/Ajax将能够使用JSF生成的新HTML数据对其进行更新.

This way the <span id="aggiuniAuto"> is always present in the client side, so JS/Ajax will be able to update it with the new HTML data generated by JSF.

这篇关于p:commandButton更新在ui:include中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆