【问题标题】:Absolute reRendering using RichFaces使用 RichFaces 进行绝对重新渲染
【发布时间】:2011-01-10 10:16:57
【问题描述】:

我的问题是 RichFaces reRender 在元素树中的当前元素“下”不起作用;只有上层元素会被重新渲染。

有没有什么方法可以使用 AJAX 访问底层元素?

任何帮助将不胜感激! 丹尼尔

编辑我将此问题编辑为更一般的问题。如果对原始问题感兴趣,请查看修订。

【问题讨论】:

    标签: jsf richfaces rerender


    【解决方案1】:
    • reRender 用于提供您要重新渲染的目标对象的 id(在同一命名容器内 - 最常见的是 form
    • 根据 html 规范,id 应该是唯一的字符串
    • reRender 允许动态值 - 即 reRender="#{myBean.currentItemsToRerender}

    基于此,我认为你应该能够实现你想要的(虽然还不完全清楚)

    更新:

    UIComponent.findComponent(..) 有一个定义明确的算法来解析 id。因此,对于绝对引用,您的 reRendered id 应该 : 开头,然后继续通过命名容器的层次结构。

    【讨论】:

      【解决方案2】:

      下面是changePanel111() 更改下部元素内容的示例:

      <h:form id="form" prependId="true">
          <rich:panel id="PANEL1">
              <h:outputText id="PANEL1TEXT" value="#{ajaxTestBean.panel1}"/>
              <rich:panel id="PANEL11">
                  <h:outputText id="PANEL11TEXT" value="#{ajaxTestBean.panel11}"/>
                  <rich:panel id="PANEL111">
                      <h:outputText id="PANEL111TEXT" value="#{ajaxTestBean.panel111}"/>
                  </rich:panel>
              </rich:panel>
              <rich:panel id="PANEL12">
                  <h:outputText id="PANEL12TEXT" value="#{ajaxTestBean.panel12}"/>
                  <br/>
                  <a4j:commandLink value="CHANGE PANEL12" action="#{ajaxTestBean.changePanel12}">
                      <a4j:support reRender="PANEL12" event="onclick"/>
                  </a4j:commandLink>
                  <br/>
                  <a4j:commandLink value="CHANGE PANEL111" action="#{ajaxTestBean.changePanel111}">
                      <a4j:support reRender="form:PANEL111" event="onclick"/>
                  </a4j:commandLink>
              </rich:panel>
          </rich:panel>
      </h:form>
      

      注意下面的元素需要如何标识为form:PANEL111

      希望这会有所帮助!

      【讨论】:

        【解决方案3】:

        reRender 也可以指向表单之外的任何组件。例如这有效:

        <h:form>
          <a4j:commandButton reRender="panel"/>
        </h:form>
        
        <h:panelGrid id="panel">
        ...
        </h:panelGrid>
        

        【讨论】:

          【解决方案4】:

          对于我的 MyFaces+Richfaces 应用程序,&lt;rich:panel&gt; 标记未按所选答案中的说明工作。当我将其更改为&lt;a4j:outputPanel ajaxRendered="true" /&gt; 时,它开始按照此处“<a4j:commandLink> Not Rerendering”的方式工作

          配置:MyFaces 2.1.10(用于模板的 Facelets)和 Richfaces 4.2.3。

          希望这会有所帮助。

          【讨论】:

            猜你喜欢
            • 2011-03-12
            • 2023-04-09
            • 2012-02-03
            • 2012-02-25
            • 2013-01-03
            • 1970-01-01
            • 2012-03-27
            • 2011-10-08
            • 2011-07-27
            相关资源
            最近更新 更多