Foros de discusión
Primefaces fileUpload with mode = "simple"
Konstantinos Triantafyllou, modificado hace 8 años.
Primefaces fileUpload with mode = "simple"
New Member Mensajes: 6 Fecha de incorporación: 25/04/13 Mensajes recientes
Hi everyone,
Is there a demo portlet showcasing a fileUpload with primefaces using mode="simple". All i have found is the advanced mode which is the ajax version.
I tried to make this work on my installation but i didn't have success. I m using LR 6.2 with 3.2.5-GA6 and Primefaces 4.
In my form i have this:
<h:form id="appForm" enctype="multipart/form-data" style="width:70%;">
.....
<p:fileUpload value="#{appCreationBean.file}" mode="simple"/>
......
In my web.xml :
<?xml version="1.0"?>
<web-app version="2.5" 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_2_5.xsd">
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</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>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
<context-param>
<param-name>com.liferay.faces.bridge.primeFileUploadForceResourceURL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>
</web-app>
And in my backing bean:
@ManagedBean(name = "appCreationBean")
@ViewScoped
public class ApplicationCreationBean implements Serializable {
......................
private UploadedFile file;
public UploadedFile getFile() {
return file;
}
public void setFile(UploadedFile file) {
this.file = file;
}
Kind Regards,
Kostas
Is there a demo portlet showcasing a fileUpload with primefaces using mode="simple". All i have found is the advanced mode which is the ajax version.
I tried to make this work on my installation but i didn't have success. I m using LR 6.2 with 3.2.5-GA6 and Primefaces 4.
In my form i have this:
<h:form id="appForm" enctype="multipart/form-data" style="width:70%;">
.....
<p:fileUpload value="#{appCreationBean.file}" mode="simple"/>
......
In my web.xml :
<?xml version="1.0"?>
<web-app version="2.5" 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_2_5.xsd">
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</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>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
<context-param>
<param-name>com.liferay.faces.bridge.primeFileUploadForceResourceURL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>
</web-app>
And in my backing bean:
@ManagedBean(name = "appCreationBean")
@ViewScoped
public class ApplicationCreationBean implements Serializable {
......................
private UploadedFile file;
public UploadedFile getFile() {
return file;
}
public void setFile(UploadedFile file) {
this.file = file;
}
Kind Regards,
Kostas
Philip White, modificado hace 8 años.
RE: Primefaces fileUpload with mode = "simple"
Junior Member Mensajes: 76 Fecha de incorporación: 11/03/15 Mensajes recientes
Hello Konstantinos,
Primefaces FileUploader expects an uploaded file of type org.primefaces.model.DefaultUploadedFile, but you are using com.liferay.faces.util.model.UploadedFile.
So your Java code should end up looking something like this:
This has been tested to work in our environments.
Hope this helps!
Phil
Primefaces FileUploader expects an uploaded file of type org.primefaces.model.DefaultUploadedFile, but you are using com.liferay.faces.util.model.UploadedFile.
So your Java code should end up looking something like this:
import org.primefaces.model.DefaultUploadedFile;
private DefaultUploadedFile file;
public DefaultUploadedFile getFile() {
return file;
}
public void setFile(DefaultUploadedFile file) {
this.file = file;
}
This has been tested to work in our environments.
Hope this helps!
Phil
Konstantinos Triantafyllou, modificado hace 8 años.
RE: Primefaces fileUpload with mode = "simple"
New Member Mensajes: 6 Fecha de incorporación: 25/04/13 Mensajes recientes
I tried the changes you suggested and it didn't work for me. Perhaps i am missing something else. Is there a demo portlet with this functionality (mode="simple") that i can deploy and test?
Kind Regards,
Kostas
Kind Regards,
Kostas
Philip White, modificado hace 8 años.
RE: Primefaces fileUpload with mode = "simple"
Junior Member Mensajes: 76 Fecha de incorporación: 11/03/15 Mensajes recientes
Hello Konstantinos,
Please remove the following context-param (since it's no longer neccessary according to FACES-1240) and see if that fixes your issue:
If this does not fix your problem, please let us know!
Phil
Please remove the following context-param (since it's no longer neccessary according to FACES-1240) and see if that fixes your issue:
<context-param>
<param-name>com.liferay.faces.bridge.primeFileUploadForceResourceURL</param-name>
<param-value>true</param-value>
</context-param>
If this does not fix your problem, please let us know!
Phil