PrimeFaces on Tomcat - problems

UI Components for JSF
Post Reply
primehthb
Posts: 52
Joined: 12 Dec 2010, 22:19

20 Jan 2011, 00:15

Hi,

I've been using PrimeFaces 2.2 RC2 on Glassfish 3 with great efficacy. However, now I am using it with Tomcat 6 for another project.

I installed the following libs:

jsf-api.jar
jsf-impl.jar
standard.jar (JSTL)
jstl.jar

I'm just testing with the fileUpload component. It renders correctly and seems to behave correctly at the client side. But then I realize it doesn't call my ManagedBean. In fact it seems to ignore all references to a fileUploadListener altogether.
My .xhtml:

Code: Select all

 <h:body>
        <h:form>
        <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}" allowTypes="*.docx" label="Upload"  />
        </h:form>
    </h:body>
My ManagedBean:

Code: Select all

@ManagedBean(name="fileUploadController")
@RequestScoped
public class FileUploadMBean {

 

       public void handleFileUpload(FileUploadEvent event) {
           
           String file = event.getFile().getFileName();
           System.out.println(event.getFile().getFileName());
          

       }
Nothing happens.

No errors or exceptions are generated.
Even changing

Code: Select all

fileUploadListener="#{fileUploadController.handleFileUpload}"
to a random non-existing function does not generate any errors.

Am I missing something?

healeyb
Posts: 365
Joined: 07 Apr 2010, 16:05

20 Jan 2011, 06:34

This filter (below) is required in your deployment descriptor, and watch
out for any conflicting java code containing @WebFilter annotations,
which can be a real pain to debug.

(clearly changes will and may be needed to the exact text included here...)

web.xml
----------

Code: Select all

<filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter
        </filter-class>
        <init-param>
            <param-name>uploadDirectory</param-name>
            <param-value>c:\upload</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

primehthb
Posts: 52
Joined: 12 Dec 2010, 22:19

25 Jan 2011, 13:52

Hi,

That worked. Thanks.

I had completely forgotten about that filter.

Thanks.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests