Primefaces 4.0 fileupload not working with prettyfaces and spring security

Splash Forums PrettyFaces Users Primefaces 4.0 fileupload not working with prettyfaces and spring security

This topic contains 3 replies, has 3 voices, and was last updated by  syscreat 2 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25640

    nari_prettyface
    Participant

    Hi All,

    fileUploadListener is not invoking when I upload file with primefaces 4.0 , prettyfaces 3.3.3 and spring security 3.1.4. but its working fine when I remove prettyfaces configuration.

    I think the problem with spring security and prettyfaces configuration with primefaces 4.

    below is my configuration:

    web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 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"
    	version="3.0">
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>   
    		   classpath*:/META-INF/main-context.xml		
    		   /WEB-INF/spring-security.xml    
    	 </param-value>
    	</context-param>
    
    	<!-- This param will help in development phase, but must be changed to Production 
    		when application is deployed in production server -->
    	<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>#{themeSwitcherBean.gp.theme}</param-value>
    	</context-param>
    
    	<context-param>
    		<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
    		<param-value>true</param-value>
    	</context-param>
    	
    	<context-param>
            <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
            <param-value>
                  /WEB-INF/facelets/tags/blockdialog.taglib.xml
            </param-value>
        </context-param>
        <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
        </context-param>
    <listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	<filter>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<url-pattern>/*</url-pattern>
    		<dispatcher>FORWARD</dispatcher>
       		<dispatcher>REQUEST</dispatcher>
    	</filter-mapping>
    	
       <!-- To upload files in PF, you should define this filer and map it to faces servlet -->
    	<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>Faces Servlet</servlet-name>
    		<!-- Dispatcher is set to forward since we are using prettyfaces -->
    		<dispatcher>FORWARD</dispatcher>
    		<dispatcher>REQUEST</dispatcher>
    	</filter-mapping>
    	
    		<filter>
    		<filter-name>Pretty Filter</filter-name>
    		<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    		<async-supported>true</async-supported>
    	</filter>
    
    	<filter-mapping>
    		<filter-name>Pretty Filter</filter-name>
    		<url-pattern>/*</url-pattern>
    		<dispatcher>FORWARD</dispatcher>
    		<dispatcher>REQUEST</dispatcher>
    		<dispatcher>ERROR</dispatcher>
    		<dispatcher>ASYNC</dispatcher>
    	</filter-mapping>
    	<servlet>
    		<servlet-name>Faces Servlet</servlet-name>
    		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    	</servlet>
    	<!--servlet is used for doing export functionality-->
    	<servlet>
    		<servlet-name>exportServlet</servlet-name>
    		<servlet-class>com.school.management.reports.ExportServlet</servlet-class>
    	</servlet>
         <servlet>
    		<servlet-name>jasperReportsBrowserServlet</servlet-name>
    		<servlet-class>com.school.management.reports.JasperReportsBrowserServlet</servlet-class>
    	</servlet>
    	<servlet>
    		<description></description>
    		<display-name>DisplayImage</display-name>
    		<servlet-name>DisplayImage</servlet-name>
    		<servlet-class>com.school.management.utils.DisplayImage</servlet-class>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>Faces Servlet</servlet-name>
    		<url-pattern>*.jsf</url-pattern>
    	</servlet-mapping>
    	<servlet-mapping>
    		<servlet-name>exportServlet</servlet-name>
    		<url-pattern>/exportServlet</url-pattern>
    	</servlet-mapping>
    	<servlet-mapping>
    		<servlet-name>jasperReportsBrowserServlet</servlet-name>
    		<url-pattern>/jasperReportsBrowserServlet</url-pattern>
    	</servlet-mapping>
    	<servlet-mapping>
    		<servlet-name>DisplayImage</servlet-name>
    		<url-pattern>/DisplayImage</url-pattern>
    	</servlet-mapping>
    	<welcome-file-list>
    		<welcome-file>index.xhtml</welcome-file>
    	</welcome-file-list>
    	<session-config>
    		<session-timeout>30</session-timeout>
    	</session-config>
    </web-app>

    pom.xml:

    <!-- Spring Security -->
    		<dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-core</artifactId>
    			<version>3.2.1.CI-SNAPSHOT</version>
    		</dependency>
    
    		<dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-web</artifactId>
    			<version>3.2.1.CI-SNAPSHOT</version>
    		</dependency>
    
    		<dependency>
    			<groupId>org.springframework.security</groupId>
    			<artifactId>spring-security-config</artifactId>
    			<version>3.2.1.CI-SNAPSHOT</version>
    		</dependency>
                    <dependency>
    			<groupId>org.primefaces</groupId>
    			<artifactId>primefaces</artifactId>
    			<version>4.0</version>
    		</dependency>
    
    		<dependency>
    			<groupId>com.ocpsoft</groupId>
    			<artifactId>prettyfaces-jsf2</artifactId>
    			<version>3.3.3</version>
    		</dependency>
    		<!-- JSF -->
    		<dependency>
    			<groupId>com.sun.faces</groupId>
    			<artifactId>jsf-api</artifactId>
    			<version>2.2.4</version>
    		</dependency>
    		<dependency>
    			<groupId>com.sun.faces</groupId>
    			<artifactId>jsf-impl</artifactId>
    			<version>2.2.4</version>
    		</dependency>
    		<!-- File Upload Needed for PF to work -->
    		<dependency>
    			<groupId>commons-fileupload</groupId>
    			<artifactId>commons-fileupload</artifactId>
    			<version>1.3</version>
    		</dependency>
    		<dependency>
    			<groupId>commons-io</groupId>
    			<artifactId>commons-io</artifactId>
    			<version>2.4</version>
    		</dependency>

    sample.xhtml:

    <p:dialog header="Photo Upload" widgetVar="photoUploadDialog" resizable="false" modal="true" appendTo="@(body)">  
          <h:form>  
               <p:growl id="message" showDetail="true"/> 
       
    <h:panelGrid columns="1">
                    <h:outputLabel value="Select Image: *" />
                    <p:fileUpload id="image" value="#{userManagedBean.imageVO.file}" mode="advanced" 
                     update=":createUserForm:userPhotoPanel,:updateUserForm:updateUserPhotoPanel" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" 
                     fileUploadListener="#{userManagedBean.photoUpload}"/> 
                </h:panelGrid> 
          </h:form>   
       </p:dialog>

    please help me to solve this issue

    #25642

    nari_prettyface
    Participant

    i found solution for this After Thorough reading of Ocpsoft FAQ and apache 2.5 doc.
    Solution:

    we should add below piece of line to context.xml file to our weapp folder under META-INF folder
    <Context allowCasualMultipartParsing=”true”>
    <!– no content required –>
    </Context>

    folder structure for maven:

    webapp/META-INF/context.xml

    Thanks to all….:)

    #25644

    Nice to hear someone found the FAQ entry I wrote on this topic some time ago. 😉

    #26088

    syscreat
    Participant

    Does someone found a solution for Glassfish server? Glassfish doesn’t supports <Context allowCasualMultipartParsing=”true”> option.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Comments are closed.