Vote count:
0
I'm developing a Web Project with JSF and PrimeFaces 5.0. Although there are many forums about this problem I can't find the solution with the FileUpload. The issue is that when I Uplaod a file handler method is never invoked
This is my code:
HTML page:
<!DOCTYPE html>
<html xmlns="http://ift.tt/lH0Osb"
xmlns:ui="http://ift.tt/KsEgXx"
xmlns:h="http://ift.tt/HjFrZb"
xmlns:f="http://ift.tt/HcrI1S"
xmlns:p="http://ift.tt/HjFrZc">
<ui:composition template="/WEB-INF/templates/template.xhtml">
<ui:define name="content">
<f:view>
<p:panel id="panel" header="Registros de Fuente" style="width:100%;">
<h:form enctype="multipart-data">
<p:fileUpload fileUploadListener="#{registrosBean.handleFileUpload}"
required="true" mode="advanced" dragDropSupport="false"
multiple="true" sizeLimit="1000000" fileLimit="5" update="messages"
allowTypes="/(\.|\/)(gif|jpe?g|png|pdf|doc|docx)$/">
<p:growl id="messages" showDetail="true" />
</p:fileUpload>
</h:form>
<h:form enctype="multipart/form-data">
<p:fileUpload value="#{registrosBean.file}" mode="simple" />
<p:commandButton value="Submit" ajax="false"/>
</h:form>
</p:panel>
</f:view>
</ui:define>
</ui:composition>
</html>
BEAN:
@Component("registrosBean")
@ViewScoped
@ManagedBean
public class RegistroBean extends GenericBean<Registrofuente> implements Serializable {
public void handleFileUpload(FileUploadEvent event) {
System.out.println("SOME CONSOLE MESSAGE");
}
public void cogerArchivos( ) {
System.out.println("SOME CONSOLE MESSAGE");
}
public UploadedFile file;
/**
* @return the file
*/
public UploadedFile getFile() {
return file;
}
/**
* @param file the file to set
*/
public void setFile(UploadedFile file) {
System.out.println("SOME CONSOLE MESSAGE");
this.file = file;
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://ift.tt/nSRXKP" xmlns:xsi="http://ift.tt/ra1lAU" version="3.0" xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP">
<display-name>UNAC</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-context.xml</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>aristo</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>pages/login.jsf</welcome-file>
</welcome-file-list>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<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>10240</param-value> <!-- 10 Mb -->
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
Some aditional information about my project
- JSF 2.1
- IDE: Eclipse
- Jboss 7.1
It's important to say that I've already added the commons-io and commons-fileupload libraries to the WEB-INF\lib folder
I've been many days and consulted many forums about this issue and I can not find the solution, any suggestion will help. Thank you
asked 29 secs ago
Aucun commentaire:
Enregistrer un commentaire