【问题标题】:What does the error "AjaxUpdate component not found for id:" mean and how to resolve it?错误“AjaxUpdate component not found for id:”是什么意思以及如何解决它?
【发布时间】:2014-01-02 13:21:13
【问题描述】:

我有这样的代码:

<a4j:commandButton value="Submit" action="#{myBean.method1}" reRender="outputPanel,statusPanel,viewLog">
            <a4j:support event="oncomplete" action="#" reRender="outputPanel,statusPanel,viewLog" ajaxSingle="true"></a4j:support>
            <a4j:support event="onclick" action="#{myBean.method2}" reRender="statusPanel"/>
        </a4j:commandButton>

这在 JSF 1.x 中运行良好。但在迁移到 JSF 2.1 后,我收到错误“AjaxUpdate component not found for id:”。一旦我点击提交按钮。 JSF 正在寻找哪个组件以及“AjaxUpdate 组件”是什么意思?而这个的替代品是什么?

要求是,当用户点击按钮时,我需要调用 "method2" 并更新 "statusPanel" ,这只是一个文本框。然后“method1”需要触发。此外,一旦“method1”完成,我需要使用更新的信息重新渲染所有面板。

【问题讨论】:

    标签: jsf jsf-2 richfaces


    【解决方案1】:

    这是一个警告(仅在开发模式下显示)。它表示 ajax 在树中找不到要更新的元素(未呈现 outputPanel、statusPanel、viewLog 之一,因此不存在于 DOM 树中)。有关该问题的更多详细信息,请参阅此处:http://livedemo.exadel.com/richfaces-demo/richfaces/outputPanel.jsf?c=outputPanel&tab=usage

    而且你可以简化你的代码(目前它做的太多了(它可能发送多达三个!请求做一个动作)),改进的版本可能看起来像这样:

    <a4j:commandButton value="Submit"
                       action="#{myBean.method2}"
                       reRender="statusPanel"
                       oncomplete="callMethod1AndRenderAllPanels()"/>
    
    <a4j:jsFunction name="callMethod1AndRenderAllPanels"
                    action="#{myBean.method1}"
                    ajaxSingle="true"
                    reRender="outputPanel,statusPanel,viewLog"/>
    

    顺便说一句,我没有理由不一次做这一切:

    <a4j:commandButton value="Submit"
                       action="#{myBean.invokeBothMethods}"
                       reRender="outputPanel,statusPanel,viewLog"/>
    

    【讨论】:

    • 感谢 Andrey 的回复.. AjaxUpdate 错误现在没有出现.. 但我仍然无法让它工作(UI 中没有发生任何事情).. 我有一个疑问是如果从 bean 方法“method1”抛出任何异常,reRender 代码将被执行或不执行。如果没有,即使方法抛出异常,我们如何确保 reRender 被调用..跨度>
    【解决方案2】:

    我也遇到了同样的问题,通过添加相应的状态组件解决了。

    <a4j:commandButton id="apply-reject-filter" value="Filter" style="width:120px"  styleClass="dlg-button"
                              action="#{bean}"
                              title="Filter"
                               status="waitStatus1"
                              limitToList="true" reRender="rejectedParticipantList"/>
    
    
    <a4j:status id="waitStatus1" forceId="true"
                onstart="javascript:Richfaces.showModalPanel('waitModalPanel1');"
                onstop="javascript:Richfaces.hideModalPanel('waitModalPanel1');" />
    
    <rich:modalPanel id="waitModalPanel1" autosized="true" width="200"
               height="120" moveable="false" resizeable="false">
               <f:facet name="header">
                   <h:outputText value="Processing" />
               </f:facet>
               <h:outputText value="Please wait..." />
               <center>
                   <h:graphicImage value="/images/ajax-loader.gif" />
               </center>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-22
      • 2021-06-25
      • 1970-01-01
      • 2013-08-04
      • 1970-01-01
      • 2019-12-05
      • 2013-04-02
      相关资源
      最近更新 更多