vcattin
vcattin

Reputation: 687

Primefaces fileupload filter when web.xml not used

I want to use the primefaces fileupload control in my jboss 7 web application. As I don't use any web.xml (not required with Java EE 6), how can I specify the filter required to make the fileupload work properly? Should I create a web.xml for that or can I use annotations instead?

Thank you in advance!

Upvotes: 2

Views: 2377

Answers (1)

BalusC
BalusC

Reputation: 1108642

Technically, you should indeed be creating a web.xml file yourself. It's not that hard, just create a file in /WEB-INF/web.xml with the following kickoff template:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

    <!-- Your config here. -->

</web-app>

If you've really a hard head in and have some big aversion against "XML boilerplate", then you could always homebrew a filter class which extends the PrimeFaces file upload filter with the desired @WebFilter annotation.

package com.example;

import javax.servlet.annotation.WebFilter;
import org.primefaces.webapp.filter.FileUploadFilter;

@WebFilter("*.jsf") // Or @WebFilter(servletNames={"Faces Servlet"})
public class AnnotatedPrimeFacesFileUploadFilter extends FileUploadFilter {
    // NOOP.
}

Upvotes: 2

Related Questions