Board index JavaServer Faces General fileUpload listener not firing

fileUpload listener not firing

Components, Ajax Framework, Utilities and More.

Post 13 Apr 2011, 17:55

Posts: 11
Hello,

I've been trying to update my applications Primefaces to version 3 but I still can't get the fileUpload to work.

Current versions:
Primefaces 3.0.M1 (but tried all above version 3)
Mojarra 2.0.5
Spring 3.0.5.RELEASE
Spring Web Flow 2.3.0.RELEASE

web.xml (upload filter is the first filter in the list and it's called)
  <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
  </filter-mapping>



My upload controller (doesn't fire):
public class FileUploadController {
    private com.opensymphony.xwork2.util.logging.Logger logger = LoggerFactory.getLogger(FileUploadController.class);
    public void handleFileUpload(FileUploadEvent event) {
      logger.debug("Succesful", event.getFile().getFileName() + " is uploaded.");
      FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
      FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}


Upload controller bean config:
<bean id="fileUploadController" class="pt.m24.yotta.controllers.FileUploadController" scope="request" />


And finally the xhtml where I try to use it, I thought it might be a flow related problem so I also tried it outside any flow:
<h:form enctype="multipart/form-data" >
    <p:growl id="msg" showDetail="true"/>
    <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
            mode="advanced"
            update="msg"
            auto="true"
            sizeLimit="1000000"
            allowTypes="png,gif,jpg"/>
</h:form>


So, the progress bar fills but nothing happens on the page, the controller is not fired and no exception or debug message in the log.
I would appreciate some help with what I might be doing wrong, thank you in advance.
Using PrimeFaces v3.0, JSF Mojarra 2.0.6 and Tomcat 6


Posts: 42
Location: Xanthi/Greece

same problem to me ... of all versions of primefaces ;/
PrimeFaces 3.0 RC1 version . Netbeans 7.0.1 . Apache Tomcat 7.0.22 . Firefox 7.0.1 & Google Chrome ,
Mandriva 2011 & Windows Home Server 2011 & Windows 8 Developer Preview .


Posts: 11
Hello kataras, with Primefaces version 2.2 and a very similar version of what I posted fileUpload worked. But I really wanted to upgrade prime to version 3.
Using PrimeFaces v3.0, JSF Mojarra 2.0.6 and Tomcat 6


Posts: 42
Location: Xanthi/Greece

for me .. doesnt work to 2.2.1 and 3 Millstone 1 ;// i dont know what i make whrong... if you know how we can fix it at 2.2.1 can you help me from MSN/FB or teamviewer ? cuz i am new on primefaces.... expect the 4 years of java programmer ;p


FIXED
look
at http://primefaces.prime.com.tr/forum/viewtopic.php?f=3&t=9066
PrimeFaces 3.0 RC1 version . Netbeans 7.0.1 . Apache Tomcat 7.0.22 . Firefox 7.0.1 & Google Chrome ,
Mandriva 2011 & Windows Home Server 2011 & Windows 8 Developer Preview .


Posts: 11
I forgot about the commons-io library, I have it already. I had version 1.4 and just updated to 2.0.1. Still no luck :(
Using PrimeFaces v3.0, JSF Mojarra 2.0.6 and Tomcat 6


Posts: 42
Location: Xanthi/Greece

just make it like we made at other post and it should working.. if isnt working add me to kataras2007@hotmail.com to help you isntantly ;)
PrimeFaces 3.0 RC1 version . Netbeans 7.0.1 . Apache Tomcat 7.0.22 . Firefox 7.0.1 & Google Chrome ,
Mandriva 2011 & Windows Home Server 2011 & Windows 8 Developer Preview .


Posts: 11
I've tried that custom javascript you have there in your post but no luck. Your configuration is very different from mine so I guess the problem I'm having doesn't happen with you.

Still I would like if someone could shed some light over this...
Using PrimeFaces v3.0, JSF Mojarra 2.0.6 and Tomcat 6


Posts: 21
File upload listener+ p:tab
Hey i had met with a strange problem. File upload lisener works fine when the file upload component is used in first tab(the second tab contains another form to display something else.).But when the file upload component is used in second tab (the first tab contains something to display with a separate form) the listener is not at all being called.

Primefaces version:3.0M1
Glass fish: 3.0

Jars used:Commons.fileupoad-1.2.2

Here is my xhtml code
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Upload</title>
    </h:head>
    <h:body>
        <p:tabView dynamic="true" id="Test"
                   widgetVar="Tabs">
            <p:tab title="Tab08" id="Tab08">
                <h:form id="uploadForm"   prependId="false">
                    First tab
                </h:form>
            </p:tab>
            <p:tab title="second">
                <h:form id="secondform"  prependId="false"  enctype="multipart/form-data">
                    <p:growl id="messages" showDetail="true"/>
                    <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
                                  mode="advanced"
                                  update="messages"
                                  sizeLimit="1000000"
                                  allowTypes="png,gif,jpg" />
                </h:form>
            </p:tab>
        </p:tabView>
    </h:body>
</html>


And here is my web .xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>none</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/Login.xhtml</welcome-file>
    </welcome-file-list>
    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter     </filter-class>
    </filter>
    <filter>
        <filter-name>Character Encoding Filter</filter-name>
        <filter-class>org.primefaces.examples.filter.CharacterEncodingFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>Character Encoding Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>   
</web-app>



Please let me know what is my mistake. My demand is to use separate forms for every tabs.


Posts: 21
I got this working on jboss 6 final by adding

<Loader delegate="true" />


to context.xml in META-INF

Hope that helps

Craig


Posts: 11
I hoped the listener would fire with version 3.0.M2-SNAPSHOT but still no luck, anyone knows whats the problem ?

I guess the problem here is primefaces 3 + webflow, anyone has this working ?
Using PrimeFaces v3.0, JSF Mojarra 2.0.6 and Tomcat 6

Next

Return to General