-
1. Re: Fileupload works great..!! ---data and jpg dont show aft
ilya_shaikovsky Apr 29, 2008 8:21 AM (in response to nohacks)add the info about:
*any errors?
*paint method
*File Upload page code
*web.xml upload params
*RF version used. -
2. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 29, 2008 11:16 AM (in response to nohacks)Thanks for your reply !!!
===================
Log output
===================
org.richfaces.component.html.HtmlSpacer
--->> listener photos : 281
Phil check Is file -->> : false
item.getFileName() --->> phil_cactus_close1.JPG
item.getData().length --->> 36819
29Apr0802_phil_cactus_close1.JPG
2008-04-29 10:51:02,343 DEBUG com.testApp.java.util.FileUploadBean com.testApp.java.util.FileUploadBean listener - in try box now
2008-04-29 10:51:02,343 DEBUG com.testApp.java.util.DbUtil com.testApp.java.util.DbUtil connectToDb - DW IP Addr: 72.73.1.24
2008-04-29 10:51:02,343 DEBUG com.testApp.java.util.DbUtil com.testApp.java.util.DbUtil connectToDb - jdbc:oracle:thin:@test1710//:2321/orclSid
2008-04-29 10:51:02,359 DEBUG org.ajax4jsf.resource.InternetResourceService org.ajax4jsf.resource.InternetResourceService serviceResource - Get content from cache for resource org.richfaces.renderkit.html.images.ProgressBarAnimatedBg/DATB/eAFjmPUcAAIeAYI_
2008-04-29 10:51:02,359 DEBUG org.ajax4jsf.webapp.BaseFilter org.ajax4jsf.webapp.BaseFilter doFilter - Finished request processing total time 156ms for uri: /testApp/a4j_3_2_1-SNAPSHOTorg.richfaces.renderkit.html.images.ProgressBarAnimatedBg/DATB/eAFjmPUcAAIeAYI_.jsf
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.webapp.BaseFilter org.ajax4jsf.webapp.BaseFilter doFilter - Filter start request processing at 4/29/08 10:51 AM for uri: /testApp/profileMembersCongrats.jsf
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.webapp.BaseFilter org.ajax4jsf.webapp.BaseFilter lookupCharacterEncoding - Incoming request has Content-Type header with character encoding UTF-8
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.webapp.BaseFilter org.ajax4jsf.webapp.BaseFilter handleRequest - Filter request output to XML
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.webapp.BaseXMLFilter org.ajax4jsf.webapp.BaseXMLFilter doXmlFilter - XML filter service start processing request
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.webapp.BaseFilter org.ajax4jsf.webapp.BaseFilter doFilter - Filter start request processing at 4/29/08 10:51 AM for uri: /testApp/profileMembersCongrats.jsf
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.webapp.BaseFilter org.ajax4jsf.webapp.BaseFilter doFilter - Not is faces request, Filter perform not-xml parsing chain
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener beforePhase - Process before phase RESTORE_VIEW 1
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.application.AjaxStateHolder org.ajax4jsf.application.AjaxStateHolder getInstance - Request for a view states holder instance
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.component.UIAjaxSupport org.ajax4jsf.component.UIAjaxSupport setParent - Called setParent for AjaxSupport component with parent : org.richfaces.component.html.HtmlFileUpload
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.component.UIAjaxSupport org.ajax4jsf.component.UIAjaxSupport setParent - Detect newly created component
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.component.AjaxRegionBrige org.ajax4jsf.component.AjaxRegionBrige restoreState - Restore State of UIAjaxComponent with Id j_id_jsp_110879174_0
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener afterPhase - Process after phase RESTORE_VIEW 1
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener beforePhase - Process before phase APPLY_REQUEST_VALUES 2
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.renderkit.RendererBase org.ajax4jsf.renderkit.RendererBase decode - Start decoding of component j_id_jsp_110879174_0 with class org.ajax4jsf.component.AjaxViewRoot
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.renderkit.AjaxContainerRenderer org.ajax4jsf.renderkit.AjaxContainerRenderer doDecode - Decode ajax request status for j_id_jsp_110879174_0
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.component.AjaxRegionBrige org.ajax4jsf.component.AjaxRegionBrige setSubmitted - Submitted AJAX request - Queue Event to AjaxListeners
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.renderkit.RendererBase org.ajax4jsf.renderkit.RendererBase decode - Start decoding of component f1:j_id_jsp_110879174_61 with class org.ajax4jsf.component.html.HtmlAjaxSupport
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.renderkit.RendererBase org.ajax4jsf.renderkit.RendererBase decode - Start decoding of component f1:j_id16 with class org.richfaces.component.html.HtmlProgressBar
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.renderkit.RendererBase org.ajax4jsf.renderkit.RendererBase decode - Start decoding of component f1:upload with class org.richfaces.component.html.HtmlFileUpload
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener afterPhase - Process after phase APPLY_REQUEST_VALUES 2
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener beforePhase - Process before phase PROCESS_VALIDATIONS 3
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener afterPhase - Process after phase PROCESS_VALIDATIONS 3
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener beforePhase - Process before phase UPDATE_MODEL_VALUES 4
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener afterPhase - Process after phase UPDATE_MODEL_VALUES 4
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener beforePhase - Process before phase INVOKE_APPLICATION 5
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener afterPhase - Process after phase INVOKE_APPLICATION 5
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener beforePhase - Process before phase RENDER_RESPONSE 6
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.event.AjaxPhaseListener org.ajax4jsf.event.AjaxPhaseListener beforePhase - PhaseListener enter Before RenderView Phase with ViewId /profileMembersCongrats.jsp and RenderKitId HTML_BASIC
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.application.AjaxViewHandler org.ajax4jsf.application.AjaxViewHandler processAjaxEvents - Process AJAX events to calculate areas.
2008-04-29 10:51:02,375 DEBUG org.ajax4jsf.component.AjaxRegionBrige org.ajax4jsf.component.AjaxRegionBrige broadcast - Send Event to AjaxListeners from AjaxContainer with Id j_id_jsp_110879174_0
2008-04-29 10:51:02,421 DEBUG org.ajax4jsf.webapp.FilterServletResponseWrapper org.ajax4jsf.webapp.FilterServletResponseWrapper getWriter - Create StringWriter for buffer servlet output
2008-04-29 10:51:02,421 DEBUG com.testApp org.apache.jsp.profileMembersCongrats_jsp _jspService - dwInstance: yes
2008-04-29 10:51:02,421 DEBUG com.testApp org.apache.jsp.profileMembersCongrats_jsp _jspService - showQueryLink: true
2008-04-29 10:51:02,421 DEBUG org.ajax4jsf.renderkit.RendererBase org.ajax4jsf.renderkit.RendererBase encodeBegin - Start encoding of component j_id_jsp_110879174_0 with class org.ajax4jsf.component.AjaxViewRoot
2008-04-29 10:51:02,421 DEBUG org.ajax4jsf.renderkit.AjaxContainerRenderer org.ajax4jsf.renderkit.AjaxContainerRenderer encodeAjax - AjaxView RenderChildren() components for AJAX request
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxRendererUtils org.ajax4jsf.renderkit.AjaxRendererUtils getAbsoluteId - Calculate absolute ID for component j_id_jsp_110879174_0 as :j_id_jsp_110879174_0
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path : ID j_id_jsp_110879174_0
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path : ID j_id17
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path : ID j_id_jsp_110879174_1
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path : ID f1
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path :f1: ID j_id18
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path :f1: ID j_id_jsp_110879174_3
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path :f1: ID j_id_jsp_110879174_4
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path :f1: ID j_id_jsp_110879174_5
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path :f1: ID j_id_jsp_110879174_6
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path :f1: ID j_id_jsp_110879174_7
2008-04-29 10:51:02,437 DEBUG org.ajax4jsf.renderkit.AjaxChildrenRenderer org.ajax4jsf.renderkit.AjaxChildrenRenderer encodeAjaxChildren - AjaxView encodeChild component for AJAX request with at path :f1: ID j_id_jsp_110879174_8
2008-04-2
Don't see any errors....but lots of output..
================
web.xml
================
<context-param>
<param-name>saveStateInClient</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name> javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</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.sun.faces.verifyObjects</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>DEFAULT</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</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>1000000</param-value>
</init-param>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
<filter-mapping>
<filter-name>ajax4jsf</filter-name>
<servlet-name>Faces Servlet</servlet-name>
FORWARD
REQUEST
INCLUDE
ERROR
</filter-mapping>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
REQUEST
FORWARD
INCLUDE
</filter-mapping>
===========================
RF Verison
April 25, 2008 snapshot
richfaces-ui-3.2.1.snap.jar
richfaces-impl-3.2.1-snap.jar
richfaces-api-3.2.1-snap.jar
=======================
/**
* @author Ilya Shaikovsky
*
* Update Proc for saving pictures to table/disk
* 4/2/2008 PFW
*/
public class FileUploadBean{
private Connection mConn;
private static final Logger mLogger = Logger.getLogger(FileUploadBean.class);
String baseFile = "setuptestApp";
ResourceBundle rb = ResourceBundle.getBundle(baseFile);
private ArrayList files = new ArrayList();
private int uploadsAvailable = 5;
private boolean autoUpload = 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{
String returnImagePath = "";
int memberLoggedIn = 0;
// go check who is logged in here
System.out.println("Phil check Is file -->> : " + event.getUploadItem().isFile());
UploadItem item = event.getUploadItem();
RichFile file = new RichFile();
file.setLength(item.getData().length);
file.setName(item.getFileName());
file.setData(item.getData());
files.add(file);
uploadsAvailable--;
System.out.println(" " );
System.out.println("item.getFileName() --->> " + item.getFileName());
System.out.println("item.getData().length --->> " + item.getData().length);
System.out.println(" " );
// insert image name in _photos table
try
{
//.... Database save and inserts here
}
}
public static String nowPhil(String dateFormat) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());
}
public String clearUploadData() {
files.clear();
setUploadsAvailable(5);
return null;
}
public ArrayList getFiles() {
return files;
}
public void setFiles(ArrayList 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;
}
} -
3. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 29, 2008 11:18 AM (in response to nohacks)Changed name from file to richfile.java
===========
public class RichFile {
private String Name;
private long length;
private byte[] data;
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public long getLength() {
return length;
}
public void setLength(long length) {
this.length = length;
}
} -
4. Re: Fileupload works great..!! ---data and jpg dont show aft
ilya_shaikovsky Apr 29, 2008 11:31 AM (in response to nohacks)Please try to remove dupicated filter definition at first.
Also paste mediaOutput page code. -
5. Re: Fileupload works great..!! ---data and jpg dont show aft
ilya_shaikovsky Apr 29, 2008 11:32 AM (in response to nohacks)sorry I've meant fileUpload page code.
-
6. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 29, 2008 11:41 AM (in response to nohacks)sorry I've meant fileUpload page code.
from where..???
The log file??? -
7. Re: Fileupload works great..!! ---data and jpg dont show aft
ilya_shaikovsky Apr 29, 2008 11:48 AM (in response to nohacks)no I've meant - if you use file upload defined just as on demosite or changed it? (your xhtml or jsp code where fileUpload defined)
-
8. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 29, 2008 12:03 PM (in response to nohacks)Web xml updated to one filter...same issue.
================================<context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>blueSky</param-value> </context-param> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</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>1000000</param-value> </init-param> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping>
=================================
File upload code from page.
same as demo....
================================<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%> <tr bgcolor="seashell" > <td> < ttable border="0" width="750" CELLPADDING="2" CELLSPACING="0" align="left"> <tr valign="top" align="center"> <td colspan="3" > <br/><br/> <font color="black" size="2"> <h:outputText styleClass="bold2" value="Congratulations - You are a new member of NetFixUp.com" /><br/> <h:outputText styleClass="bold2" value="Add a few photos now...then " /><br/> <h:outputText styleClass="bold2" value="Click on Home and login " /><br/> </td> </tr> <tr height="25" > <td></td> <td></td> </tr> <tr valign="top" > <td width="34" > <font color="black" size="2"><h:outputText styleClass="bold2" value="User Name" /></font> <h:inputText id = "memberUserId" styleClass = "inputDisplay" tabindex = "1" size = "35" value = "#{NetFixUpFormBean.memberUserId}"/> </td> <td width="34" > <font color="black" size="2"><h:outputText styleClass="bold2" value="Password" /></font> <h:inputText id = "memberPassword" styleClass = "inputDisplay" tabindex = "2" size = "35" value = "#{NetFixUpFormBean.memberPassword}"/> </td> </tr> <tr> <td colspan="2" > <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"> <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> <h:panelGrid columns="2"> <a4j:mediaOutput element="img" mimeType="image/jpeg" createContent="#{fileUploadBean.paint}" value="#{row}" style="width:100px; height:100px;" /> <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> </td> </tr> <tr height="225" > <td> </td> </tr>
-
9. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 29, 2008 1:45 PM (in response to nohacks)Does it look right ??
Phil -
10. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 29, 2008 3:13 PM (in response to nohacks)Ok Ilya,
I copied the exact example into my project.
I get the same results...no picture/file display refresh.
This is the demo code from 3.2.1 works on the war file I have local but not in my project.
What am I missing?? Same results on ff and ie.
Phil
====================================
faces-config.xml
<managed-bean>
<managed-bean-name>fileUploadBean2</managed-bean-name>
<managed-bean-class>com.testApp.java.utilFileUpload.FileUploadBean2</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
=======================
=======================
FileUploadBean2
=======================
/**
*
*/
package com.testApp.java.utilFileUpload;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
/**
* @author Ilya Shaikovsky
*
*/
public class FileUploadBean2{
private ArrayList files = new ArrayList();
private int uploadsAvailable = 5;
private boolean autoUpload = false;
public int getSize() {
if (getFiles().size()>0){
return getFiles().size();
}else
{
return 0;
}
}
public FileUploadBean2() {
}
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 ArrayList getFiles() {
return files;
}
public void setFiles(ArrayList 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;
}
}
====================================
File.java
===================================
package com.testApp.java.utilFileUpload;
public class File {
private String Name;
private long length;
private byte[] data;
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public long getLength() {
return length;
}
public void setLength(long length) {
this.length = length;
}
}
==================================
jsf
===============================
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
.top {
vertical-align: top;
}
.info {
height: 202px;
overflow: auto;
}
<h:outputText styleClass="bold2" value="File upload Test area" />
<h:panelGrid columns="2" columnClasses="top,top">
<rich:fileUpload fileUploadListener="#{fileUploadBean2.listener}"
maxFilesQuantity="#{fileUploadBean2.uploadsAvailable}"
id="upload"
immediateUpload="#{fileUploadBean2.autoUpload}"
acceptedTypes="jpg, gif, png, bmp">
<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="#{fileUploadBean2.size==0}" />
<rich:dataGrid columns="1" value="#{fileUploadBean2.files}"
var="file" rowKeyVar="row">
<rich:panel>
<h:panelGrid columns="2">
<a4j:mediaOutput element="img" mimeType="image/jpeg"
createContent="#{fileUploadBean2.paint}" value="#{row}"
style="width:100px; height:100px;" />
<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"/>
<a4j:commandButton action="#{fileUploadBean2.clearUploadData}"
reRender="info, upload" value="Clear Uploaded Data"
rendered="#{fileUploadBean2.size>0}" />
</h:panelGroup>
</h:panelGrid> -
11. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 29, 2008 5:34 PM (in response to nohacks)Any Help out there ???
Phil -
12. Re: Fileupload works great..!! ---data and jpg dont show aft
andrei_exadel Apr 30, 2008 5:27 AM (in response to nohacks)Nohacks,
What is scope (request, session) of 'FileUploadBean2' bean?
It should be session scope. Otherwise information will be lost and rerendering will have not effect. -
13. Re: Fileupload works great..!! ---data and jpg dont show aft
ilya_shaikovsky Apr 30, 2008 5:49 AM (in response to nohacks)yes as far as i see from faces config snippet - you use request scope. It wrong. change it to session.
-
14. Re: Fileupload works great..!! ---data and jpg dont show aft
nohacks Apr 30, 2008 10:28 AM (in response to nohacks)
******* Works Great !!! *************
Thanks guys,
This really rocks....Thanks for all your help.
You guys are the best...!!!!!!
**********************************
Thanks Phil