【问题标题】:JSF Richfaces PopupPanel refresh form not workingJSF Richfaces PopupPanel 刷新表单不起作用
【发布时间】:2023-04-05 14:33:01
【问题描述】:

在以下情况下,我对 Rich:popupPanel 上的数据有疑问:

  1. 当用户第一次打开弹出面板时,值会从 bean 中获取并显示出来。
  2. 用户更改了一些值,然后决定不保存更改并点击关闭按钮。
  3. 然后他再次打开弹出窗口。当对话框再次打开时,在 backing bean 中,相关性的值被正确地更改回以前的值(调用 load()),但此更新不会反映在 UI 中。 用户可以看到他之前(第 2 步)选择的值,而不是支持 bean 上的值。

您是否碰巧知道任何解决方案,一旦在浏览器中打开后备 bean,就可以强制使用来自支持 bean 的值来更新弹出面板的组件? 如果数据显示在单独的页面上,而不是在 popupPanel 上,我没有这个问题,但我需要使用需求中的弹出面板。

代码如下: 1. 打开弹出面板的组件

<a4j:commandLink id="config" value="open" action="#{bean.load()}"
oncomplete="#{rich:component('configPopUp:pp')}.show();" execute="@this">                           
</a4j:commandLink>
  1. 弹出式面板

     <rich:popupPanel id="ConfigPopUp"  width="800" height="350" title=" "> 
     <h:form id="ConfigForm">
            <div class="row " style="margin: 0px">
              <div >
                <a4j:commandButton styleClass="pull-right" id="ConfigSave"
                    actionListener="#{bean.saveConfiguration()}"
                    value="#{text['Configuration.save']}" immediate="true">
                </a4j:commandButton>
            </div>
        </div>                      
    
         <ui:repeat
            value="#{bean.selectedValues}"  var="current" varStatus="i">
            <div class="row" style="margin: 0px">
                <div class="col-sm-4 col-sm-offset-1 ">
                    <h:outputText value="#{current.text}" />
                </div>
                <div class="col-sm-4 ">
                    <rich:select value="#{current.relevance}">
                        <f:selectItems
                            value="#{bean.relevanceOptions}"/>
                        <f:ajax event="change" render="@form" execute="@this" />
                    </rich:select>
                </div>                  
            </div>
        </ui:repeat>
    
      </h:form>
      </rich:popupPanel>
    

【问题讨论】:

    标签: jsf-2


    【解决方案1】:

    模态面板不会在 .hide() 上自动重新渲染,因此支持 bean 具有正确信息但面板不具有正确信息是“正常的”

    您可以通过将“render”属性添加到带有面板 id(或面板的 cointener 元素)的 commandLink 来修复它。

    <a4j:commandLink id="config" value="open" action="#{bean.load()}"
       oncomplete="#{rich:component('configPopUp:pp')}.show();" render ="ConfigPopUp" execute="@this">                           
    </a4j:commandLink>
    

    另一种解决方案是在弹出面板中使用 domElementAttachment = "parent",您可以在rich_modalPanel documentation 上阅读它

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 2011-06-06
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      • 2016-10-09
      • 2013-02-12
      相关资源
      最近更新 更多