2

我在这里在 Wildfly-8.0.0.CR1 上使用 Richfaces-4.3.5,从中迁移<rich:fileUpload>不适用于 JSF-2.2/Servlet-3.0。我用这个片段替换它:

<rich:popupPanel id="testPop" autosized="true">
    <h:form id="uploadF" enctype="multipart/form-data">
       <h:inputFile value="#{bean.file}">
           <a4j:ajax listener="#{bean.storeFile()}" render="@form,:fileListTbl"
               oncomplete="#{rich:component('testPop')}.hide();" />
       </h:inputFile>
    </h:form>
</rich:popupPanel>

这很好用,因为该storeFile方法被调用并且我可以bean.file正常访问。但是,我想rich:popupPanel在上传完成后关闭,所以我需要对 ajax 请求的成功/完成事件做出反应。但这似乎不可能 - 弹出窗口保持可见并且响应显然不完整(为了更好的可读性而缩进):

<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1">
  <changes>
    <update id="j_id1:javax.faces.ViewState:0">
      <[CDATA[-1186354868983349335:-5499969782208038164]]>
    </update>
    <extension id="org.richfaces.extension"><render>@component</render></extension>
  </changes>
</partial-response>

尽管 Richfaces 调试消息表明正在调用处理程序

RichFaces: Received 'success' event from <input id=uploadF:j_idt1136 ...>
RichFaces: Received 'complete' event from <input id=uploadF:j_idt1136 ...> 

所以,一个简单的问题:我怎样才能关闭弹出窗口并重新渲染组件?

4

1 回答 1

1

我不确定问题是否直接相关a4j:ajax或需要做些什么才能使其工作a4j:ajax,但下面的代码似乎可以工作f:ajax

<h:form id="formId">
    <h:commandLink value="popup"
        onclick="#{rich:component('testPop')}.show(); return false;" />
</h:form>

<rich:popupPanel id="testPop" autosized="true">
    <h:form id="uploadF" enctype="multipart/form-data">
        <h:inputFile value="#{bean.file}">
            <f:ajax listener="#{bean.storeFile()}" render="@form :fileListTbl"
                onevent="eventHandler"/>
        </h:inputFile>
    </h:form>
</rich:popupPanel>

<script>
    function eventHandler(event)
    {
        if (event.status == 'success')
        {
            #{rich:component('testPop')}.hide();
        }
    }
</script>
于 2014-08-18T14:56:07.587 回答