ajax Primefaces 对话框打开后更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15244932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 10:57:41  来源:igfitidea点击:

Primefaces Dialog Update after it is open

ajaxprimefacesdialog

提问by Zapateus

I want to update content primafaces dialog after it is opened. Is it possible? My example code is below.

我想在打开后更新内容 primafaces 对话框。是否可以?我的示例代码如下。

 <p:dialog widgetVar="pictureSaveDialog" id="pictureDialog" closable="false" >
   <p:outputPanel id="saveDialogPanel">

   <p:selectOneRadio id="options" value="#{pictureDefinitionsView.radioValue}"  >  
                <f:selectItem itemLabel="FILE" itemValue="FILE" />  
                <f:selectItem itemLabel=""  itemValue="URL" />  
         <p:ajax update="fileUpload1 fileUpload2" event="click" process="options"  />
   </p:selectOneRadio>

   <p:outputPanel id="fileUpload1" rendered="#{pictureDefinitionsView.selectedFileUpload}">   File </p:outputPanel>

 <p:outputPanel id="fileUpload2" rendered="#{pictureDefinitionsView.selectedUrlUpload}">   URL </p:outputPanel>
</p:outputPanel id="saveDialogPanel">

Bean Methods.

豆方法。

    public boolean isSelectedFileUpload(){
    return radioValue.equals("FILE");
    } 
public boolean isSelectedUrlUpload(){
    return !isSelectedFileUpload();
    }

回答by partlov

You can define p:remoteCommandwhich just update dialog, and call that command in onShowattribute:

您可以定义p:remoteCommand哪个只是更新对话框,并在onShow属性中调用该命令:

<p:remoteCommand name="updateDialog" update="saveDialogPanel"/>

<p:dialog widgetVar="pictureSaveDialog" id="pictureDialog" closable="false" onShow="updateDialog()">

If your saveDialogPanelis in some naming container be shore to add appropriate prefix to match id of component.

如果您saveDialogPanel在某个命名容器中,请添加适当的前缀以匹配组件的 id。

回答by Daniel

You better refresh the dialog content before its being open

您最好在打开之前刷新对话框内容

Your p:commandButton/p:ajax should have the following:

您的 p:commandButton/p:ajax 应具有以下内容:

update="pictureDialog" onsuccess="pictureSaveDialog.show()"