1

I have a problem with primefaces 4.0 + TomEE, when I use fileUpload primeface's component the odd times I use it the event FileUploadRenderer#decode() is not triggered. It's quite annoying because the even times it works without any problem moreover I can't get any kind of error message.

After of writing my question here I've been reading and testing the solution of How to use PrimeFaces p:fileUpload? Listener method is never invoked with no success.

Please find my attached code:

web.xml

 <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    <init-param>
        <param-name>thresholdSize</param-name>
        <param-value>51200</param-value>
    </init-param>
    <init-param>
        <param-name>uploadDirectory</param-name>
        <param-value>C:\bin</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter>
    <filter-name>SecurityFilter</filter-name>
    <filter-class>es.mypackage.SecurityFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>SecurityFilter</filter-name>
    <url-pattern>/xhtml/*</url-pattern>
</filter-mapping>

xhtml

 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
template="../layout/template.xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">

<ui:define name="menu">
    <h:form id="menuForm">
        <p:menu model="#{menuManager.menu}" />
    </h:form>
</ui:define>

<ui:define name="content">
    <h:form id="gestionFicherosForm">
        <p:growl id="messages" showDetail="true" />
        <p:panel header="Gestion De Ficheros">
            <h:panelGrid columns="2">
                <h:outputText value="Añadir ficheros:" />
                <p:fileUpload
                    fileUploadListener="#{gestionFicheros.handleFile1Upload}"
                    mode="advanced" dragDropSupport="true" auto="true" update="messages, ficherosSubidos"
                    invalidFileMessage="Tipo de archivo no permitido." label="Examinar..."
                    multiple="true"
                    allowTypes="/(\.|\/)(csv|xls|xlsx)$/" />
            </h:panelGrid>
        </p:panel>
        <br />
        ...
        </h:form>
  </ui:define>
</ui:composition>

backing bean

    @ManagedBean
    @ViewScoped
    public class GestionFicheros implements Serializable {
    ...
    public void handleFile1Upload(FileUploadEvent event) {
    if (files == null) {
        files = new ArrayList<File>();
    }
    files.add(new File(event.getFile(),TipoFichero.AYDEN));
    FacesMessage msg = new FacesMessage("Succesful", event.getFile()
            .getFileName() + " subido.");
    FacesContext.getCurrentInstance().addMessage(null, msg);
    logger.info("fichero "+event.getFile().getFileName()+" subido.");
    }
    ...

Could be the security filter who is interfering in the normal request process? but sometimes?

Any suggestions would be welcome.

Community
  • 1
  • 1
AlvaroCachoperro
  • 711
  • 6
  • 12
  • 1
    Did you really read the solution in http://stackoverflow.com/questions/8875818/how-to-use-primefaces-pfileupload-listener-method-is-never-invoked/8880083#8880083 ? Your code doesn't adhere point 3. – BalusC Nov 04 '13 at 14:58
  • I don't know if I've misunderstood the concept of nested forms, I mean as far as I know I've put parallel forms and not nested. Where do you see the nested forms? Thank you for your quick answer!! – AlvaroCachoperro Nov 04 '13 at 15:32
  • I mean, point 3 of the first block (the "You need to ensure the following" list). Your form is missing `enctype`. – BalusC Nov 04 '13 at 15:35
  • O_O the fault was mine, read too fast XD. I have to take a while to retest this issue with more attention with your post anyway I've added enctype to the form with no success I think it shouldn't be enctype only. – AlvaroCachoperro Nov 04 '13 at 17:21

0 Answers0