[richfaces-svn-commits] JBoss Rich Faces SVN: r6323 - trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Feb 25 09:45:40 EST 2008


Author: dsvyatobatsko
Date: 2008-02-25 09:45:40 -0500 (Mon, 25 Feb 2008)
New Revision: 6323

Modified:
   trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/UIFileUpload.java
Log:
added constants for component type/family + reformatting

Modified: trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/UIFileUpload.java
===================================================================
--- trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/UIFileUpload.java	2008-02-25 14:02:41 UTC (rev 6322)
+++ trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/UIFileUpload.java	2008-02-25 14:45:40 UTC (rev 6323)
@@ -7,8 +7,6 @@
 import javax.faces.component.UIInput;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.ActionListener;
 import javax.faces.event.FacesEvent;
 import javax.servlet.http.HttpServletRequest;
 
@@ -25,161 +23,174 @@
  */
 public abstract class UIFileUpload extends UIInput {
 
-	private String localContentType;
+    /**
+     * <p>
+     * The standard component type for this component.
+     * </p>
+     */
+    public static final String COMPONENT_TYPE = "org.richfaces.component.FileUpload";
 
-	private String localFileName;
+    /**
+     * <p>
+     * The standard component family for this component.
+     * </p>
+     */
+    public static final String COMPONENT_FAMILY = "org.richfaces.component.FileUpload";
 
-	private Integer localFileSize;
+    private String localContentType;
 
-	private InputStream localInputStream;
+    private String localFileName;
 
-	// @Override
-	// public void processUpdates(FacesContext context) {
-	// ValueExpression dataBinding = getValueExpression("data");
-	// if (dataBinding != null) {
-	// Class clazz = dataBinding.getType(context.getELContext());
-	// if (clazz.isAssignableFrom(InputStream.class)) {
-	// dataBinding.setValue(context.getELContext(),
-	// getLocalInputStream());
-	// } else if (clazz.isAssignableFrom(byte[].class)) {
-	// byte[] bytes = null;
-	// if (getLocalInputStream() != null) {
-	// ByteArrayOutputStream bos = new ByteArrayOutputStream();
-	// try {
-	// byte[] buffer = new byte[512];
-	// int read = getLocalInputStream().read(buffer);
-	// while (read != -1) {
-	// bos.write(buffer, 0, read);
-	// read = getLocalInputStream().read(buffer);
-	// }
-	// bytes = bos.toByteArray();
-	// } catch (IOException e) {
-	// throw new RuntimeException(e);
-	// }
-	// }
-	// dataBinding.setValue(context.getELContext(), bytes);
-	// }
-	//
-	// if (getLocalContentType() != null) {
-	// ValueExpression valueExpression = getValueExpression("contentType");
-	// if (valueExpression != null) {
-	// valueExpression.setValue(context.getELContext(),
-	// getLocalContentType());
-	// }
-	// }
-	//
-	// if (getLocalFileName() != null) {
-	// ValueExpression valueExpression = getValueExpression("fileName");
-	// if (valueExpression != null) {
-	// valueExpression.setValue(context.getELContext(),
-	// getLocalFileName());
-	// }
-	// }
-	//
-	// if (getLocalFileSize() != null) {
-	// ValueExpression valueExpression = getValueExpression("fileSize");
-	// if (valueExpression != null) {
-	// valueExpression.setValue(context.getELContext(),
-	// getLocalFileSize());
-	// }
-	// }
-	// }
-	// }
+    private Integer localFileSize;
 
-	public String getLocalContentType() {
-		return localContentType;
-	}
+    private InputStream localInputStream;
 
-	public void setLocalContentType(String localContentType) {
-		this.localContentType = localContentType;
-	}
+    // @Override
+    // public void processUpdates(FacesContext context) {
+    // ValueExpression dataBinding = getValueExpression("data");
+    // if (dataBinding != null) {
+    // Class clazz = dataBinding.getType(context.getELContext());
+    // if (clazz.isAssignableFrom(InputStream.class)) {
+    // dataBinding.setValue(context.getELContext(),
+    // getLocalInputStream());
+    // } else if (clazz.isAssignableFrom(byte[].class)) {
+    // byte[] bytes = null;
+    // if (getLocalInputStream() != null) {
+    // ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    // try {
+    // byte[] buffer = new byte[512];
+    // int read = getLocalInputStream().read(buffer);
+    // while (read != -1) {
+    // bos.write(buffer, 0, read);
+    // read = getLocalInputStream().read(buffer);
+    // }
+    // bytes = bos.toByteArray();
+    // } catch (IOException e) {
+    // throw new RuntimeException(e);
+    // }
+    // }
+    // dataBinding.setValue(context.getELContext(), bytes);
+    // }
+    //
+    // if (getLocalContentType() != null) {
+    // ValueExpression valueExpression = getValueExpression("contentType");
+    // if (valueExpression != null) {
+    // valueExpression.setValue(context.getELContext(),
+    // getLocalContentType());
+    // }
+    // }
+    //
+    // if (getLocalFileName() != null) {
+    // ValueExpression valueExpression = getValueExpression("fileName");
+    // if (valueExpression != null) {
+    // valueExpression.setValue(context.getELContext(),
+    // getLocalFileName());
+    // }
+    // }
+    //
+    // if (getLocalFileSize() != null) {
+    // ValueExpression valueExpression = getValueExpression("fileSize");
+    // if (valueExpression != null) {
+    // valueExpression.setValue(context.getELContext(),
+    // getLocalFileSize());
+    // }
+    // }
+    // }
+    // }
 
-	public String getLocalFileName() {
-		return localFileName;
-	}
+    public String getLocalContentType() {
+        return localContentType;
+    }
 
-	public void setLocalFileName(String localFileName) {
-		this.localFileName = localFileName;
-	}
+    public void setLocalContentType(String localContentType) {
+        this.localContentType = localContentType;
+    }
 
-	public Integer getLocalFileSize() {
-		return localFileSize;
-	}
+    public String getLocalFileName() {
+        return localFileName;
+    }
 
-	public void setLocalFileSize(Integer localFileSize) {
-		this.localFileSize = localFileSize;
-	}
+    public void setLocalFileName(String localFileName) {
+        this.localFileName = localFileName;
+    }
 
-	public InputStream getLocalInputStream() {
-		return localInputStream;
-	}
+    public Integer getLocalFileSize() {
+        return localFileSize;
+    }
 
-	public void setLocalInputStream(InputStream localInputStream) {
-		this.localInputStream = localInputStream;
-	}
+    public void setLocalFileSize(Integer localFileSize) {
+        this.localFileSize = localFileSize;
+    }
 
-	public abstract void setAccept(String accept);
+    public InputStream getLocalInputStream() {
+        return localInputStream;
+    }
 
-	public abstract String getAccept();
+    public void setLocalInputStream(InputStream localInputStream) {
+        this.localInputStream = localInputStream;
+    }
 
-	public abstract String getStyleClass();
+    public abstract void setAccept(String accept);
 
-	public abstract String getStyle();
+    public abstract String getAccept();
 
-	public abstract void setStyleClass(String styleClass);
+    public abstract String getStyleClass();
 
-	public abstract void setStyle(String style);
+    public abstract String getStyle();
 
-	public abstract MethodExpression getFileUploadListener();
+    public abstract void setStyleClass(String styleClass);
 
-	public abstract void setFileUploadListener(MethodExpression scrollerListener);
+    public abstract void setStyle(String style);
 
-	public void addFileUploadListener(FileUploadListener listener) {
-		addFacesListener(listener);
-	}
+    public abstract MethodExpression getFileUploadListener();
 
-	public FileUploadListener[] getFileUploadListeners() {
-		return (FileUploadListener[]) getFacesListeners(FileUploadListener.class);
-	}
+    public abstract void setFileUploadListener(MethodExpression scrollerListener);
 
-	public void removeFileUploadListener(FileUploadListener listener) {
-		removeFacesListener(listener);
-	}
+    public void addFileUploadListener(FileUploadListener listener) {
+        addFacesListener(listener);
+    }
 
-	public void broadcast(FacesEvent e) {
-		
-		super.broadcast(e);
-		
-		if (e instanceof UploadEvent) {
-			// XXX BTW, why doesn't UploadEvent accept any listeners?
+    public FileUploadListener[] getFileUploadListeners() {
+        return (FileUploadListener[]) getFacesListeners(FileUploadListener.class);
+    }
 
-			FacesContext facesContext = FacesContext.getCurrentInstance();
-			MethodExpression binding = getFileUploadListener();
-			if (binding != null) {
-				binding.invoke(facesContext.getELContext(), new Object[] { e });
-			}		
-			
-		}else {
-		    FacesContext facesContext = FacesContext.getCurrentInstance();
-		    ExternalContext externalContext = facesContext.getExternalContext();
-		    HttpServletRequest request = (HttpServletRequest)externalContext.getRequest();
-		    if ("progress".equals(request.getParameter("action"))) {
-			    AjaxContext ajaxContext = AjaxContextImpl
-				    .getCurrentInstance(facesContext);
-			    String uid = request.getParameter("uid");
+    public void removeFileUploadListener(FileUploadListener listener) {
+        removeFacesListener(listener);
+    }
 
-			    Map<String, Object> sessionMap = externalContext.getSessionMap();
+    public void broadcast(FacesEvent e) {
 
-			    Map<String, MultipartRequest> sessions = (Map<String, MultipartRequest>) sessionMap
-				    .get(MultipartFilter.REQUESTS_SESSIONS_BEAN_NAME);
-			    if (sessions != null) {
-				MultipartRequest multipartRequest = sessions.get(uid);
-				if (multipartRequest != null) {
-				    ajaxContext.setResponseData(multipartRequest.getSize());
-				}
-			    }
-			} 
-		}
+        super.broadcast(e);
 
-	}
+        if (e instanceof UploadEvent) {
+            // XXX BTW, why doesn't UploadEvent accept any listeners?
+
+            FacesContext facesContext = FacesContext.getCurrentInstance();
+            MethodExpression binding = getFileUploadListener();
+            if (binding != null) {
+                binding.invoke(facesContext.getELContext(), new Object[] { e });
+            }
+
+        } else {
+            FacesContext facesContext = FacesContext.getCurrentInstance();
+            ExternalContext externalContext = facesContext.getExternalContext();
+            HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
+            if ("progress".equals(request.getParameter("action"))) {
+                AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(facesContext);
+                String uid = request.getParameter("uid");
+
+                Map<String, Object> sessionMap = externalContext.getSessionMap();
+
+                Map<String, MultipartRequest> sessions = (Map<String, MultipartRequest>) sessionMap
+                        .get(MultipartFilter.REQUESTS_SESSIONS_BEAN_NAME);
+                if (sessions != null) {
+                    MultipartRequest multipartRequest = sessions.get(uid);
+                    if (multipartRequest != null) {
+                        ajaxContext.setResponseData(multipartRequest.getSize());
+                    }
+                }
+            }
+        }
+
+    }
 }




More information about the richfaces-svn-commits mailing list