5 Replies Latest reply on Jul 15, 2008 5:17 AM by Mirek Okonoiewski

    onuploadcomplete don't execute if page with rich:fileUpload

    Kto ToTaki Newbie

      The problem :
      onuploadcomplete event in <rich:fileUpload doesn't execute (don't call action/actionListener og reRender)
      when page with <rich:fileUpload component is embedded in the main page using <jsp:include.

      <a4j:form id="mainForm" >
       <f:subview id="body">
       <jsp:include page="/jsf/prodcat/test/fileUpload2.jsf" flush="false"></jsp:include>
       </f:subview>
      </a4j:form>


      where fileUpload2.jsf includes code like this :

      <rich:fileUpload id="fileUpload" ... >
       <a4j:support event="onuploadcomplete" reRender="something" actionListener="#{testMBean.method}"/>
      </rich:fileUpload>
      


      Is there any easy workaround for this ?
      In my case hole application is divided into pages included into each other using <jsp:include, so there will not be ease to rewrite all code.


        • 1. Re: onuploadcomplete don't execute if page with rich:fileUpl
          Kto ToTaki Newbie

          I've forgot to add, testet also with :

          <a4j:form id="mainForm" >
           <a4j:include viewId="/jsf/prodcat/test/fileUpload2.jsf"/>
           </a4j:form>
          

          and got the same behavior.

          • 2. Re: onuploadcomplete don't execute if page with rich:fileUpl
            Andrei Markavtsov Apprentice

            It works for me fine. I tried with <a4j:include>.

            Please post more info.

            • 3. Re: onuploadcomplete don't execute if page with rich:fileUpl
              Kto ToTaki Newbie

              More info here:
              Running with richfaces-ui-3.2.2-20080603.044112-2.jar
              Start page is as follow:

              <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
              <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
              <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
              <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
              
              <f:view>
              <a4j:page>
              <html>
              <head>
               <% String contextPath = request.getContextPath(); %>
               <link rel="stylesheet" type="text/css" href="<%= contextPath %>/css/theCore.css" />
               <link rel="stylesheet" type="text/css" href="<%= contextPath %>/css/infoland.css" />
              </head>
              <body>
              
               <a4j:form id="mainForm" >
               <a4j:include viewId="/jsf/prodcat/test/fileUpload2.jsf"/>
               </a4j:form>
              
              </body>
              </html>
              </a4j:page>
              </f:view>


              And /jsf/prodcat/test/fileUpload2.jsf :
              <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
              <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
              <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
              <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
              
               <h:panelGrid id="urlExampleFil" columns="4" >
               <h:outputText value="URL eksempel 1" styleClass="labelFormatted"/>
               <h:inputText value="#{testMBean.url}" styleClass="wInputXLarge left"/>
              
               <h:outputText value="pcaUrl" styleClass="labelFormatted right"/>
               <h:inputText value="#{testMBean.pcaUrl}" style="width: 160px;"/>
               </h:panelGrid>
              
               <h:panelGrid id="fileUploadGrid" >
               <rich:fileUpload fileUploadListener="#{testMBean.fileUploaded}" >
               <a4j:support event="onuploadcomplete" reRender="urlExampleFil" actionListener="#{testMBean.getStoredUrl}"/>
               </rich:fileUpload>
               </h:panelGrid>
              


              fileUploadListener is fired ok, but onuploadcomplete is not execute at all.





              • 4. Re: onuploadcomplete don't execute if page with rich:fileUpl
                Kerdudou Ronan Apprentice

                maybe you can try a jsfunction...

                here is a part of our code :

                <rich:fileUpload
                id="rich_fileUpload"
                fileUploadListener="#{upload_handler.uploader.listener}"
                ...
                onuploadcomplete='pv_reRenderUploadZone();#{(upload_handler.uploader.maxFiles == 1 )? "closePopupUpload()":""}'>
                </rich:fileUpload>
                

                <a4j:jsFunction
                id="reRenderUpload"
                name="pv_reRenderUploadZone"
                reRender="rich_fileUpload, _modifForm, #{upload_handler.uploader.uploadZone}">
                </a4j:jsFunction>
                


                • 5. Re: onuploadcomplete don't execute if page with rich:fileUpl
                  Mirek Okonoiewski Newbie

                  Yes, it works. Thank you for your tips.