3 Replies Latest reply on Apr 4, 2011 9:07 AM by kevin 2

    rich:fileUpload: A4J is not defined using a4j:outputPanel with ajaxRendered=true

    kevin 2 Newbie

      Hello !

       

      Still using RichFaces 3.3.3Final.

       

      Now, I have an issue using the rich:fileUpload component in combination with a4j:outputPanel having the ajaxRendered attribute set to true.

       

      I use the outputPanel in my application for error handling, this works fine normally. It is coded like this:

       

      <a4j:outputPanel id="errorPanel" ajaxRendered="true">
           <rich:modalPanel id="errorWindowId" showWhenRendered="#{apiException}">
                <f:facet name="header">
                     <h:outputText value="Error" />
                </f:facet>
      
                <!--
                     Error display
                     ...
                -->
           </rich:modalPanel>
      </a4j:outputPanel>
      

       

      "apiException" is an attribute set in the request used to show the modalPanel.

       

      Then, I added a rich:fileUpload component which should display errors using the above modalPanel :

       

      <a4j:form id="uploadForm">
           <rich:fileUpload id="uploadFileInput"
                 fileUploadListener="#{fileUpload.processUpload}"
                 maxFilesQuantity="1">
                <a4j:support event="onuploadcomplete" action="#{errorMessage.display}"               onsubmit="#{rich:component('uploadFileInput')}.clear();"/>
                <a4j:support event="onsizerejected" action="#{fileUpload.sizeRejected}"
                     onsubmit="#{rich:component('uploadFileInput')}.clear();"/>
           </rich:fileUpload>
      
           <a4j:commandButton id="uploadFormButton" 
                              title="validate"
                              value="validate"
                              onclick="if(#{rich:component('uploadFileInput')}.entries.length==1){#{rich:component('uploadFileInput')}.upload();}else{alert('#{upload['warning.upload.empty']}');}">
           </a4j:commandButton>
      </a4j:form>
      

       

      Both onuploadcomplete and onsizerejected events call an bean action which put the attribute "apiException" in the request.

      Actually, the processUpload method does this but it seems to reRender a hidden iframe so I got the following JavaScript errors :

       

      A4J is not defined

      ModalPanel is not defined

       

      I've also tried to use the submitForm() JS method on the a4j:commandButton onclick but the result was not as expected (see here: http://community.jboss.org/message/590067#590067)

       

      Please could someone help me to solve this issue...

       

      Thank you !

       

      KL