PrimeFaces RequestContext.getCurrentInstance()。update()无效

时间:2014-04-03 16:28:24

标签: jsf-2 primefaces

我使用对话框架:

  

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”,当我单击commandButton“idBtSaveDir”时,方法saveAdress被调用,idAdress中的值被复制到idFormStore中的其他inputtext

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()更新( “idFormStore:idPanelStore”)

但是我重新加载了我输入的所有页面,所以我必须把它放在RequestContext.getCurrentInstance()。update?

2 个答案:

答案 0 :(得分:6)

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

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

答案 1 :(得分:0)

您可以将更新放在xhtml中:

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