【问题标题】:PrimeFaces RequestContext.getCurrentInstance().update() not workingPrimeFaces RequestContext.getCurrentInstance().update() 不工作
【发布时间】:2014-05-15 15:14:25
【问题描述】:

我使用的对话框框架:

http://www.primefaces.org/showcase-labs/ui/dialogFrameworkData.jsf

我创建一个文件 view_test.xhtml

<html  xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" >
<h:head>
    <title>Dialogo Prueba</title>
</h:head>
<h:body>
    <h:form id="idFormTest">
        <h:panelGrid id="idPgAdressStore" columns="2" columnClasses="col1,col2">
        <h:outputLabel for="idAdress" value="Adress: " />  
        <p:inputText id="idAdress"  label="Adresss" size="40" value="#{storeBean.au.strAdress}"/>
        <f:facet name="footer">
            <h:panelGrid width="100%" columns="2" style="text-align:center">
                <p:commandButton id="idBtSaveDir" value="Save" actionListener="#{storeBean.saveAdress}" />
                <p:commandButton id="idBtCancelDir" actionListener="#{storeBean.closeAdress}"  value="Cancel"/>
            </h:panelGrid>
        </f:facet>
        </h:panelGrid>
    </h:form>
</h:body>

此对话框打开其他表单“idFormStore”,当我单击命令按钮“idBtSaveDir”时,将调用方法 saveAdress 并将 idAdress 中的值复制到 idFormStore 中的其他输入文本中

public void saveAdress(ActionEvent event) {
    au.setAdressStore(au.getStrAdress());
    RequestContext.getCurrentInstance().update("idFormStore");
    RequestContext.getCurrentInstance().closeDialog("/pages/logistica/store/view_test");
}

我正在更新表单 idFormStore,但它没有更新 RequestContext.getCurrentInstance().update("idFormStore") 不起作用,

我还将 panelgrid 放在 inputext 的位置并且不更新, RequestContext.getCurrentInstance().update("idFormStore:idPanelStore")

但是我重新加载了所有页面,我输入的值出现了,那么我必须在 RequestContext.getCurrentInstance().update 中放入什么?

【问题讨论】:

    标签: jsf-2 primefaces


    【解决方案1】:

    您可以将更新放在 xhmtl 中:

    <p:commandButton id="idBtSaveDir" value="Save" ajax="true" update=":idFormTest" actionListener="#{storeBean.saveAdress}" />
    

    【讨论】:

      【解决方案2】:

      对话框框架在 iframe 中打开对话框。 要更新父视图中的值,请将此 ajax 事件添加到打开对话框的 commandButton 或 commonadLink:

      <p:commandButton value="Open Dialog" actionListener"...">
         <p:ajax event="dialogReturn" update="idFormStore"/>
      </p:commandButton>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-12-05
        • 1970-01-01
        • 1970-01-01
        • 2013-12-03
        • 1970-01-01
        • 2018-02-04
        • 2015-05-15
        相关资源
        最近更新 更多