0 Replies Latest reply on Oct 28, 2013 12:09 PM by manuel.moroni

    <rich:fileUpload> can't call the listener

    manuel.moroni

      hi,

      i'm trying to develop a modalpanel in which the user can upload multiple files.

      unfortunately it seems that the listener that should be called from the <rich:fileUpload> component never fires.

      once the files have been uploaded the <h:commandButton> should process the files by calling a procedures that saves them into an oracle db.

      i'v attached the code.

      nevertheless i notices that IE might have a bug.

      infact if i try to encapsulate the <rich:fileUpload> by an <h:form> the the page load the content forever and never ends so i tested the code below with chrome.

       

      following some technical details:

      appserver: weblogic 10.3

      framework: richfaces 3.3.3

      browser: chrome (but must be compatible with IE8 for now)

      jsf version: 1.2

      jdk version: 1.6


      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
      
      
      <rich:modalPanel id="panel_allegati" width="1000" height="400">
        <f:facet name="header">
        <h:panelGroup>
        <h:outputText value="Allegati"></h:outputText>
        </h:panelGroup>
        </f:facet>
        <f:facet name="controls">
        <h:panelGroup>
        <h:commandLink value="x" styleClass="hidelink" id="hidelink"/>
        <rich:componentControl for="panel_allegati" attachTo="hidelink" operation="hide" event="onclick"/>
        </h:panelGroup>
        </f:facet>
        <h:panelGrid columns="1" style="font-size:12px;">
        <h:outputText value="File Caricati a Sistema: " />
        <rich:extendedDataTable value="#{sessionContainer.findSession.allegato.allegatiList}" 
        selection="#{sessionContainer.findSession.allegato.selection}" 
        var="item" id="table_allegati" sortMode="multi" width="900" height="100" 
        selectionMode="multi" style="margin-left:auto; margin-right:auto;">
                  <rich:column sortable="false" label="Note" id="col_1">
                          <f:facet name="header">
                              <h:outputText value="Note" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:inputHidden value="#{item.idDocumento}"/>
                          <h:outputText value="#{item.descrizione}" id="note"/>
                      </rich:column>
                      <rich:column sortable="true" label="Nome File" id="col_2" filterEvent="onkeyup">
                          <f:facet name="header">
                              <h:outputText value="Nome File" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:outputText value="#{item.nome}" id="nome_file"/>
                      </rich:column>
                      <rich:column sortable="true" label="Tipo File" id="col_3" filterEvent="onkeyup">
                          <f:facet name="header">
                              <h:outputText value="Tipo File" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:outputText value="#{item.estensione}" id="tipo_file"/>
                      </rich:column>
                      <rich:column sortable="true" label="Data Upload" id="col_4">
                          <f:facet name="header">
                              <h:outputText value="Data Upload" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:outputText value="#{item.dataUpload}" id="data_upload"/>
                      </rich:column>
                      <rich:column sortable="true" label="From" id="col_5">
                          <f:facet name="header">
                              <h:outputText value="From" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:outputText value="#{item.mailFrom}" id="mail_from"/>
                      </rich:column>
                      <rich:column sortable="true" label="To" id="col_6">
                          <f:facet name="header">
                              <h:outputText value="To" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:outputText value="#{item.mailTo}" id="mail_to"/>
                      </rich:column>
                      <rich:column sortable="true" label="Subject" id="col_7">
                          <f:facet name="header">
                              <h:outputText value="Subject" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:outputText value="#{item.mailSubject}" id="mail_subject"/>
                      </rich:column>
                      <rich:column sortable="true" label="Allegati" id="col_8">
                          <f:facet name="header">
                              <h:outputText value="Allegati" style="color:#1b6e2f; font-size:12px; font-weight:bold"/>
                          </f:facet>
                          <h:outputText value="#{item.mailAllegati}" id="mail_allegati"/>
                      </rich:column>
          </rich:extendedDataTable>
        </h:panelGrid>
        <h:form enctype="multipart/form-data">
              <h:panelGrid columns="2" columnClasses="top,top">
          <rich:fileUpload fileUploadListener="#{sessionContainer.findSession.allegato.listener}"
              maxFilesQuantity="#{sessionContainer.findSession.allegato.uploadsAvailable}"
                  id="upload"
                  immediateUpload="#{sessionContainer.findSession.allegato.autoUpload}"
                  allowFlash="#{sessionContainer.findSession.allegato.useFlash}"
                  listHeight="100">
                  <a4j:support event="onuploadcomplete" reRender="info" />
          </rich:fileUpload>
          <h:panelGroup id="info">
                      <rich:panel bodyClass="info">
                          <f:facet name="header">
                              <h:outputText value="Uploaded Files Info" />
                          </f:facet>
                          <h:outputText value="No files currently uploaded"
                              rendered="#{sessionContainer.findSession.allegato.size==0}" />
                          <rich:dataGrid columns="1" value="#{sessionContainer.findSession.allegato.files}"
                              var="file" rowKeyVar="row">
                              <rich:panel bodyClass="rich-laguna-panel-no-header">
                                  <h:panelGrid columns="2">
                                      <h:panelGrid columns="2">
                                          <h:outputText value="File Name:" />
                                          <h:outputText value="#{file.name}" />
                                      </h:panelGrid>
                                  </h:panelGrid>
                              </rich:panel>
                          </rich:dataGrid>
                      </rich:panel>
                      <rich:spacer height="3"/>
                      <br />
                      <a4j:commandButton action="#{sessionContainer.findSession.allegato.clearUploadData}"
                          reRender="info, upload" value="Clear Uploaded Data"
                          rendered="#{sessionContainer.findSession.allegato.size>0}" />
                  </h:panelGroup>
          </h:panelGrid>
          </h:form>
      

        <h:commandButton value="Salva Allegato" action="#{sessionContainer.findSession.allegato.processMyFile}" image="../../static/images/salva_allegato.jpg" />

      </rich:modalPanel>