I am trying to use the ice:inputFile integrating with seam framework(version 1.1.6) in a portlet (JBoss Portal 2.4.1). It doesn't launch exception, but the log of ice:inputFile component is this:
DiskFileUpload. The InputFile was null. Upload failed.
This is my configuration.
home.xhtml
Code:
<ice:form id="formInputFile" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ice="http://www.icesoft.com/icefaces/component" >
<ice:inputFile id="inputFileComponent"
file="#{user.file}"
progressListener="#{user.progress}" />
<ice:message for="inputFileComponent" />
<ice:outputProgress
label="Uploading"
value="#{user.percent}" />
<ice:outputText value="#{user.fileLocation}" />
</ice:form>
Bean
Code:
package com.icesoft.icefaces.tutorial.component.inputfile.progress;
import java.io.File;
import java.util.EventObject;
import com.icesoft.faces.component.inputfile.InputFile;
import com.icesoft.faces.webapp.xmlhttp.PersistentFacesState;
import com.icesoft.faces.webapp.xmlhttp.RenderingException;
/**
* <p>
* A basic backing bean for a ice:inputFile component. This bean contains a
* reference to the file that is uploaded by the inputFile component.
* </p>
*/
public class User {
private File file;
private String fileLocation;
private int percent;
private PersistentFacesState state;
public User(){
state = PersistentFacesState.getInstance();
}
public File getFile() {
return file;
}
public String getFileLocation(){
return fileLocation;
}
public int getPercent() {
return percent;
}
public void setFile(File file) {
this.file = file;
fileLocation = file.getPath();
}
public void setPercent(int percent) {
this.percent = percent;
}
// Required to bind the InputFile component to its OutputProgress component.
public void progress (EventObject event) {
InputFile inputFileComponent = (InputFile)event.getSource();
percent = inputFileComponent.getFileInfo().getPercent();
try {
if (state != null) {
state.render();
}
} catch (RenderingException ee) {
System.out.println(ee.getMessage());
}
}
}
web.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener
</listener-class>
</listener>
<listener>
<listener-class>
com.icesoft.faces.util.event.servlet.ContextEventRepeater
</listener-class>
</listener>
<listener>
<listener-class>
org.jboss.seam.servlet.SeamListener
</listener-class>
</listener>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.actionURLSuffix</param-name>
<param-value>.seam</param-value>
</context-param><!--
<context-param>
<param-name>com.icesoft.faces.synchronousUpdate</param-name>
<param-value>true</param-value>
</context-param>
--><context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.synchronousUpdate</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.uploadDirectory</param-name>
<param-value>upload</param-value>
</context-param>
<!-- Filters -->
<filter>
<filter-name>Seam Exception Filter</filter-name>
<filter-class>
org.jboss.seam.servlet.SeamExceptionFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Exception Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>Seam Redirect Filter</filter-name>
<filter-class>
org.jboss.seam.servlet.SeamRedirectFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Redirect Filter</filter-name>
<url-pattern>*.seam</url-pattern>
</filter-mapping>
<!-- Faces Servlet
-->
<!-- file upload Servlet -->
<servlet>
<servlet-name>uploadServlet</servlet-name>
<servlet-class>com.icesoft.faces.component.inputfile.FileUploadServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>uploadServlet</servlet-name>
<url-pattern>/uploadHtml</url-pattern>
</servlet-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>
<servlet-name>Persistent Faces Servlet</servlet-name>
<servlet-class>
com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Blocking Servlet</servlet-name>
<servlet-class>
com.icesoft.faces.webapp.xmlhttp.BlockingServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces 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>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>
<!-- Persistent Faces Servlet Mapping
-->
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>*.iface</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Blocking Servlet</servlet-name>
<url-pattern>/block/*</url-pattern>
</servlet-mapping>
</web-app>
Anyone knows the way to solve this problem?
Thanks for you help!