This content has been marked as final.
Show 6 replies
-
1. Re: fileUploadListener=
adubovsky Jun 24, 2009 5:46 AM (in response to giannisapi)Hello,
Set inside a4j filter declaration in your web.xml:<init-param> <param-name>createTempFiles</param-name> <param-value>false</param-value> </init-param>
-
2. Re: fileUploadListener=
giannisapi Jun 24, 2009 5:54 AM (in response to giannisapi)hi,
i have already tried that but i had no luck. same problem again.
any other ideas please?
thanks in advance.
regards,
ioannis -
3. Re: fileUploadListener=
ilya_shaikovsky Jun 24, 2009 6:21 AM (in response to giannisapi)show please page and bean code.
-
4. Re: fileUploadListener=
giannisapi Jun 24, 2009 4:30 PM (in response to giannisapi)Hi,
I paste below the sources as you asked me to.package com.advert.sbeans; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import org.jboss.seam.annotations.Name; import org.richfaces.event.UploadEvent; import org.richfaces.model.UploadItem; /** * @author Ilya Shaikovsky * */ @Name("fileUploadBean") public class FileUploadBean{ private ArrayList<File> files = new ArrayList<File>(); private int uploadsAvailable = 5; private boolean autoUpload = false; private boolean useFlash = false; public int getSize() { if (getFiles().size()>0){ return getFiles().size(); }else { return 0; } } public FileUploadBean() { } public void paint(OutputStream stream, Object object) throws IOException { stream.write(getFiles().get((Integer)object).getData()); } public void listener(UploadEvent event) throws Exception{ UploadItem item = event.getUploadItem(); File file = new File(); file.setLength(item.getData().length); file.setName(item.getFileName()); file.setData(item.getData()); files.add(file); uploadsAvailable--; } public String clearUploadData() { files.clear(); setUploadsAvailable(5); return null; } public long getTimeStamp(){ return System.currentTimeMillis(); } public ArrayList<File> getFiles() { return files; } public void setFiles(ArrayList<File> files) { this.files = files; } public int getUploadsAvailable() { return uploadsAvailable; } public void setUploadsAvailable(int uploadsAvailable) { this.uploadsAvailable = uploadsAvailable; } public boolean isAutoUpload() { return autoUpload; } public void setAutoUpload(boolean autoUpload) { this.autoUpload = autoUpload; } public boolean isUseFlash() { return useFlash; } public void setUseFlash(boolean useFlash) { this.useFlash = useFlash; } }
and the xhtml page is as follows:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
xmlns:a="http://richfaces.org/a4j" template="layout/template.xhtml">
<ui:define name="body">
<style>
.top {
vertical-align: top;
}
.info {
height: 202px;
overflow: auto;
}
</style>
<h:form>
<h:panelGrid columns="2" columnClasses="top,top">
<rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
maxFilesQuantity="#{fileUploadBean.uploadsAvailable}" id="upload"
immediateUpload="#{fileUploadBean.autoUpload}"
acceptedTypes="jpg, gif, png, bmp"
allowFlash="#{fileUploadBean.useFlash}">
<a4j:support event="onuploadcomplete" reRender="info" />
</rich:fileUpload>
<h:panelGroup id="info">
<rich:panel bodyClass="info">
<f:facet name="header">
<h:outputText value="Uploaded Files Info" />
</f:facet>
<h:outputText value="No files currently uploaded"
rendered="#{fileUploadBean.size==0}" />
<rich:dataGrid columns="1" value="#{fileUploadBean.files}"
var="file" rowKeyVar="row">
<rich:panel bodyClass="rich-laguna-panel-no-header">
<h:panelGrid columns="2">
<a4j:mediaOutput element="img" mimeType="#{file.mime}"
createContent="#{fileUploadBean.paint}" value="#{row}"
style="width:100px; height:100px;" cacheable="false">
<f:param value="#{fileUploadBean.timeStamp}" name="time" />
</a4j:mediaOutput>
<h:panelGrid columns="2">
<h:outputText value="File Name:" />
<h:outputText value="#{file.name}" />
<h:outputText value="File Length(bytes):" />
<h:outputText value="#{file.length}" />
</h:panelGrid>
</h:panelGrid>
</rich:panel>
</rich:dataGrid>
</rich:panel>
<rich:spacer height="3" />
<br />
<a4j:commandButton action="#{fileUploadBean.clearUploadData}"
reRender="info, upload" value="Clear Uploaded Data"
rendered="#{fileUploadBean.size>0}" />
</h:panelGroup>
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
my web.xml is as follows:
<?xml version="1.0" ?>
<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_2_5.xsd"
version="2.5">
<init-param>
<param-name>createTempFiles</param-name>
<param-value>false</param-value>
</init-param>
<!-- RichFaces -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Suppress spurious stylesheets -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>disable</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
<param-value>disable</param-value>
</context-param>
<!-- Change load strategy to DEFAULT to disable sending scripts/styles as packs
-->
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<!-- Seam -->
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
<init-param>
<param-name>createTempFiles</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>maxRequestSize</param-name>
<param-value>200000</param-value>
</init-param>
</filter>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.web.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<!-- Facelets development mode (disable in production) -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<!-- JSF -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<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>*.seam</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>Restrict raw XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
</web-app>
Thanks for your help and your time.
regards,
ioannis -
5. Re: fileUploadListener=
giannisapi Jun 25, 2009 3:55 AM (in response to giannisapi)Hi again,
after some searching in the internet,
I deleted this :<init-param> <param-name>createTempFiles</param-name> <param-value>false</param-value> </init-param>
and added this :<filter> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> <init-param> <param-name>createTempFiles</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>maxRequestSize</param-name> <param-value>102400</param-value> </init-param> </filter>
so now my web.xml is like:<?xml version="1.0" ?> <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_2_5.xsd" version="2.5"> <!-- RichFaces --> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>blueSky</param-value> </context-param> <!-- Suppress spurious stylesheets --> <context-param> <param-name>org.richfaces.CONTROL_SKINNING</param-name> <param-value>disable</param-value> </context-param> <context-param> <param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name> <param-value>disable</param-value> </context-param> <!-- Change load strategy to DEFAULT to disable sending scripts/styles as packs --> <context-param> <param-name>org.richfaces.LoadStyleStrategy</param-name> <param-value>ALL</param-value> </context-param> <context-param> <param-name>org.richfaces.LoadScriptStrategy</param-name> <param-value>ALL</param-value> </context-param> <!-- Seam --> <listener-class>org.jboss.seam.servlet.SeamListener</listener-class> <!-- <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> <init-param> <param-name>createTempFiles</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>maxRequestSize</param-name> <param-value>200000</param-value> </init-param> --> <filter> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> <init-param> <param-name>createTempFiles</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>maxRequestSize</param-name> <param-value>102400</param-value> </init-param> </filter> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.web.SeamFilter</filter-class> <filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> <filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet-name>Seam Resource Servlet</servlet-name> <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class> <servlet-mapping> <servlet-name>Seam Resource Servlet</servlet-name> <url-pattern>/seam/resource/*</url-pattern> </servlet-mapping> <!-- Facelets development mode (disable in production) --> <context-param> <param-name>facelets.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <!-- JSF --> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.seam</url-pattern> </servlet-mapping> <security-constraint> <display-name>Restrict raw XHTML Documents</display-name> <web-resource-collection> <web-resource-name>XHTML</web-resource-name> <url-pattern>*.xhtml</url-pattern> </web-resource-collection> <auth-constraint/> </security-constraint> </web-app>
what happens now is that:
once i click the upload button for a image that i have selected. The image gets uploaded straight away. The image now is nto shown in the right panel of the file upload component and i still have the null pointer exception mentioned in the first place.
Thanks a alot for your time.
Regards,
Ioannis -
6. Re: fileUploadListener=
ilya_shaikovsky Jun 25, 2009 6:12 AM (in response to giannisapi)I'm curious about a few filter duplicate declarations present in your web.xml.