Author: andrei_exadel
Date: 2008-02-09 10:13:38 -0500 (Sat, 09 Feb 2008)
New Revision: 5976
Added:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/ProgressData.java
Modified:
trunk/sandbox/ui/fileUpload/src/main/config/component/fileUpload.xml
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/renderkit/FileUploadRendererBase.java
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartFilter.java
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
Log:
big refactoring
Modified: trunk/sandbox/ui/fileUpload/src/main/config/component/fileUpload.xml
===================================================================
--- trunk/sandbox/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-02-09
03:48:17 UTC (rev 5975)
+++ trunk/sandbox/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-02-09
15:13:38 UTC (rev 5976)
@@ -88,6 +88,16 @@
<description>this value binding receives the file size
(optional).</description>
</property>
<property>
+ <name>progressInfo</name>
+ <classname>java.lang.String</classname>
+ <description>Defines bean name where progress info should be stored
(optional).</description>
+ </property>
+ <property>
+ <name>maxFiles</name>
+ <classname>java.lang.Integer</classname>
+ <description>Defines max files count allowed for upload
(optional).</description>
+ </property>
+ <property>
<name>addStyle</name>
<classname>java.lang.String</classname>
<description>CSS style for add button</description>
Added:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/ProgressData.java
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/ProgressData.java
(rev 0)
+++
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/ProgressData.java 2008-02-09
15:13:38 UTC (rev 5976)
@@ -0,0 +1,228 @@
+/*
+ * ProgressData.java Date created: 09.02.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces.org.jboss.seam.ui.component;
+
+import java.math.BigDecimal;
+
+/**
+ * Provides progress data during file uploading progress
+ *
+ * @author "Andrey Markavtsov"
+ *
+ */
+public class ProgressData {
+
+ private Integer SCALE = 2;
+
+ /** Actual file size */
+ private Long size = 0L;
+
+ /** Seconds after process started */
+ private Long time = 0L;
+
+ /** Uploaded bytes count */
+ private Long uploaded = 0L;
+
+ /** Percent completed */
+ private Double percent = 0.0;
+
+ private Object scaleNumber(Double d) {
+ if (d != null) {
+ BigDecimal decimal = new BigDecimal(d);
+ decimal = decimal.setScale(SCALE, 0);
+ return decimal;
+ }
+ return null;
+ }
+
+ /**
+ * Gets minutes of process
+ *
+ * @return
+ */
+ public String getMm() {
+ Long mm = time / 60;
+ if (mm != null)
+ return String.valueOf(mm.intValue());
+ return null;
+ }
+
+ /**
+ * Gets seconds of process
+ *
+ * @return
+ */
+ public String getSs() {
+ Long ss = time % 60;
+ if (ss != null)
+ return String.valueOf(ss.intValue());
+ return null;
+ }
+
+ /**
+ * Gets hours of process
+ *
+ * @return
+ */
+ public String getHh() {
+ Long ss = time / 3600;
+ if (ss != null)
+ return String.valueOf(ss.intValue());
+ return null;
+ }
+
+ /**
+ * Gets days of process
+ *
+ * @return
+ */
+ public String getDd() {
+ Long ss = time / 3600 * 24;
+ if (ss != null)
+ return String.valueOf(ss.intValue());
+ return null;
+ }
+
+ /**
+ * Gets uploaded bytes count
+ *
+ * @return
+ */
+ public Object getUploadedB() {
+ return getUploaded();
+ }
+
+ /**
+ * Gets uploaded kilo bytes count
+ *
+ * @return
+ */
+ public Object getUploadedKB() {
+ Double kb = getUploaded() / 1024.0;
+ return scaleNumber(kb);
+ }
+
+ /**
+ * Gets uploaded mega bytes count
+ *
+ * @return
+ */
+ public Object getUploadedMB() {
+ Double mb = getUploaded() / (1024.0 * 1024.0);
+ return scaleNumber(mb);
+ }
+
+ /**
+ * Gets uploaded giga bytes count
+ *
+ * @return
+ */
+ public Object getUploadedGB() {
+ Double gb = getUploaded() / (1024.0 * 1024.0 * 1024.0);
+ return scaleNumber(gb);
+ }
+
+ /**
+ * Gets file size in bytes
+ *
+ * @return
+ */
+ public Object getB() {
+ return size;
+ }
+
+ /**
+ * Gets file size in kilo bytes
+ *
+ * @return
+ */
+ public Object getKB() {
+ Double kb = size / 1024.0;
+ return scaleNumber(kb);
+ }
+
+ /**
+ * Gets file size in mega bytes
+ *
+ * @return
+ */
+ public Object getMB() {
+ Double mb = size / (1024.0 * 1024.0);
+ return scaleNumber(mb);
+ }
+
+ /**
+ * Gets file size in giga bytes
+ *
+ * @return
+ */
+ public Object getGB() {
+ Double gb = size / (1024.0 * 1024.0 * 1024.0);
+ return scaleNumber(gb);
+ }
+
+ /**
+ * @return the size
+ */
+ public Long getSize() {
+ return size;
+ }
+
+ /**
+ * @param size
+ * the size to set
+ */
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+ /**
+ * @return the time
+ */
+ public Long getTime() {
+ return time;
+ }
+
+ /**
+ * @param time
+ * the time to set
+ */
+ public void setTime(Long time) {
+ this.time = time;
+ }
+
+ /**
+ * @return the uploaded
+ */
+ public Long getUploaded() {
+ return uploaded;
+ }
+
+ /**
+ * @param uploaded
+ * the uploaded to set
+ */
+ public void setUploaded(Long uploaded) {
+ this.uploaded = uploaded;
+ }
+
+ /**
+ * @return the percent
+ */
+ public Object getPercent() {
+ return scaleNumber(percent);
+ }
+
+ /**
+ * @param percent
+ * the percent to set
+ */
+ public void setPercent(Double percent) {
+ this.percent = percent;
+ }
+
+}
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-09
03:48:17 UTC (rev 5975)
+++
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/component/UIFileUpload.java 2008-02-09
15:13:38 UTC (rev 5976)
@@ -14,6 +14,7 @@
import javax.faces.context.FacesContext;
import org.richfaces.component.UIProgressBar;
+import org.richfaces.org.jboss.seam.ui.component.FileItem.Status;
/**
* JSF component class
@@ -103,10 +104,94 @@
return (this.getUploadStatus() == UPLOADING || this.getUploadStatus() == UNDER_UPLOAD);
}
- public boolean hasChildren () {
+ public boolean hasFiles () {
return this.getFileItems().size() > 0;
}
+
+ public Integer getFilesCount() {
+ return fileItems.size();
+ }
+ public boolean isCanCleanAll() {
+ boolean result = false;
+ for (FileItem item : fileItems) {
+ if (item.getStatus() != FileItem.Status.IN_PROGRESS) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+
+
+ public FileItem getFileForClean() {
+ for (FileItem item : fileItems) {
+ if (item.getStatus() != FileItem.Status.IN_PROGRESS) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ public Integer getFilesCountByStatus (Status status) {
+ Integer counter = 0;
+ for (FileItem item : fileItems) {
+ if (item.getStatus() == status) {
+ counter++;
+ }
+ }
+ return counter;
+ }
+
+ public boolean isCanAdd () {
+ boolean result = true;
+ Integer max = (Integer)getAttributes().get("maxFiles");
+ if (max != null) {
+ if (getFilesCountByStatus(Status.UPLOADED) >= max) {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ public boolean isCanUploadAll () {
+ return (null != getFileByStatus(FileItem.Status.ADDED));
+ }
+
+ public FileItem getFileInProgress () {
+ for (FileItem item : fileItems) {
+ if (item.getStatus() == FileItem.Status.IN_PROGRESS) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ public FileItem getFileByStatus (Status status) {
+ for (FileItem item : fileItems) {
+ if (item.getStatus() == status) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ public boolean hasFilesInProgress() {
+ for (FileItem item : fileItems) {
+ if (item.getStatus() == FileItem.Status.IN_PROGRESS) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void markForUpload() {
+ for (FileItem item : fileItems) {
+ if (item.getStatus() == FileItem.Status.ADDED) {
+ item.setStatus(FileItem.Status.MARKED_4_UPLOAD);
+ }
+ }
+ }
public String getLocalContentType() {
return localContentType;
Modified:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java 2008-02-09
03:48:17 UTC (rev 5975)
+++
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java 2008-02-09
15:13:38 UTC (rev 5976)
@@ -30,12 +30,16 @@
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils;
+import org.apache.commons.digester.SetRootRule;
import org.richfaces.component.UIProgressBar;
import org.richfaces.org.jboss.seam.ui.component.FileItem;
+import org.richfaces.org.jboss.seam.ui.component.ProgressData;
import org.richfaces.org.jboss.seam.ui.component.UIFileUpload;
import org.richfaces.org.jboss.seam.web.MultipartRequest;
import org.richfaces.renderkit.TemplateEncoderRendererBase;
+import sun.security.action.GetLongAction;
+
/**
* Class provides base renderer for upload file component
* @author "Andrey Markavtsov"
@@ -70,7 +74,11 @@
/** Session bean name to store the percent value of uploading process */
public static final String _percentBeanName = "__percentValue$";
+ /** Session bean name to store the percent value of uploading process */
+ public static final String _progressInfoBeanName = "__ProgressInfo$";
+
+
private static final String _reRenderAllFlag = "reRenderAll";
/* (non-Javadoc)
@@ -133,13 +141,13 @@
}
- public void encodeControlsMarkup(FacesContext context, UIComponent component)
- throws IOException {
- UIComponent header = component.getFacet("header");
- if (header != null) {
- writeScriptBody(context, header, true);
- }
- }
+// public void encodeControlsMarkup(FacesContext context, UIComponent component)
+// throws IOException {
+// UIComponent header = component.getFacet("header");
+// if (header != null) {
+// writeScriptBody(context, header, true);
+// }
+// }
/*
* (non-Javadoc)
@@ -156,10 +164,7 @@
+ ":fileItems");
}
- public String encodeStatus(UIFileUpload fileUpload) {
- return fileUpload.getUploadStatus();
- }
-
+
private void onUploadComplete(FacesContext context, String fileName,
UIFileUpload fileUpload) {
Iterator<FileItem> it = fileUpload.getFileItems().iterator();
@@ -178,58 +183,7 @@
e.getMessage();
}
}
-
- private FileItem getFileByName(UIFileUpload fileUpload, String name) {
- Iterator<FileItem> it = fileUpload.getFileItems().iterator();
- while (it.hasNext()) {
- FileItem item = it.next();
- if (item.getFullFileName().equals(name)) {
- return item;
- }
- }
- return null;
- }
-
-
- public String getActionUrl(FacesContext context) {
- AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(context);
- return ajaxContext.getAjaxActionURL(context);
- }
-
- public void encodeFileItemStatus(FacesContext context,
- UIComponent component, FileItem item) {
- ResponseWriter writer = context.getResponseWriter();
- if (item.getStatus() == FileItem.Status.IN_PROGRESS
- || item.getStatus() == FileItem.Status.UPLOADED) {
- UIComponent progressBar = getProgressBar(context, component);
- try {
- if (item.getStatus() == FileItem.Status.IN_PROGRESS) {
- HttpSession session = (HttpSession) context
- .getExternalContext().getSession(false);
-
- if (progressBar != null) {
- String exprStr = "#{" + _percentBeanName + "}";
- ValueExpression ex = context.getApplication()
- .getExpressionFactory().createValueExpression(
- context.getELContext(), exprStr,
- Integer.class);
- progressBar.setValueExpression("value", ex);
- progressBar.setId("bar");
- renderChild(context, progressBar);
- }
-
- } else if (item.getStatus() == FileItem.Status.UPLOADED) {
- UIComponent completed = progressBar.getFacet("complete");
- renderChild(context, completed);
- }
- } catch (Exception e) {
- e.getMessage();
- }
-
- }
-
- }
-
+
/*
* (non-Javadoc)
*
@@ -247,26 +201,42 @@
.getRequestParameterValuesMap();
UIFileUpload fileUpload = (UIFileUpload) component;
String action = params.get(getActionParameterName(clientId))[0];
- boolean reRenderAll = false;
if (ACTION_ADD_FILE.equals(action)) {
processAddFileAction(context, fileUpload, params);
} else if (ACTION_UPLOAD_ALL.equals(action)) {
processUploadAllAction(context, fileUpload);
- reRenderAll = true;
} else if (ACTION_CLEAR_ALL.equals(action)) {
- processClearAllAction(fileUpload);
+ processClearAllAction(context, fileUpload);
} else if (ACTION_CLEAR_FILE.equals(action)) {
processClearAction(context, fileUpload, params);
} else if (ACTION_NEXT.equals(action)) {
processNextAction(context, fileUpload);
} else if (ACTION_STOP_FILE.equals(action)) {
- reRenderAll = true;
processStopFileAction(context, fileUpload, params);
} else if (ACTION_STOP_ALL.equals(action)) {
processStopAllAction(context, fileUpload, params);
- reRenderAll = true;
}
}
+
+ private void setupSessionAttributes(FacesContext context, UIComponent component) {
+ HttpSession session = getSession(context);
+ session.setAttribute(_percentBeanName, 0);
+ String progressInfo = (String)component.getAttributes().get("progressInfo");
+ if (progressInfo != null) {
+ session.setAttribute(_progressInfoBeanName,
component.getAttributes().get("progressInfo"));
+ session.setAttribute(progressInfo, new ProgressData());
+ }
+ }
+
+ private void tearDownSessionAttributes(FacesContext context, UIComponent component)
{
+ HttpSession session = getSession(context);
+ session.removeAttribute(_percentBeanName);
+ String progressInfo = (String)component.getAttributes().get("progressInfo");
+ if (progressInfo != null) {
+ session.removeAttribute(_progressInfoBeanName);
+ session.removeAttribute(progressInfo);
+ }
+ }
private void processClearAction(FacesContext context,
UIFileUpload fileUpload, Map<String, String[]> params) {
@@ -275,45 +245,35 @@
for (String name : fileNames) {
removeFileItem(name, fileUpload);
}
+ putResponseData(context, getResponseData(fileUpload, null));
}
}
private void processStopFileAction(FacesContext context,
UIFileUpload fileUpload, Map<String, String[]> params) {
- if (params.containsKey(ACTION_STOP_FILE)) {
- String[] fileNames = params.get(ACTION_STOP_FILE);
- for (String name : fileNames) {
- FileItem item = getFileByName(fileUpload, name);
- if (item != null) {
- item.setStatus(FileItem.Status.CANCELLED);
- }
- }
- //fileUpload.setUploadStatus(UIFileUpload.READY);
- processNextAction(context, fileUpload);
+ FileItem item = fileUpload.getFileInProgress();
+ if (item != null) {
+ item.setStatus(FileItem.Status.CANCELLED);
}
+ processNextAction(context, fileUpload);
}
private void processStopAllAction(FacesContext context,
UIFileUpload fileUpload, Map<String, String[]> params) {
- for (FileItem item : fileUpload.getFileItems()) {
- if (item.getStatus() == FileItem.Status.IN_PROGRESS) {
- item.setStatus(FileItem.Status.CANCELLED);
- }
- }
- fileUpload.setUploadStatus(UIFileUpload.READY);
+ FileItem item = fileUpload.getFileByStatus(FileItem.Status.IN_PROGRESS);
+ if (item != null) {
+ item.setStatus(FileItem.Status.CANCELLED);
+ }
+ putResponseData(context, getResponseData(fileUpload, null));
}
- private void processClearAllAction(UIFileUpload fileUpload) {
- List<FileItem> toDelete = new ArrayList<FileItem>();
- for (FileItem item : fileUpload.getFileItems()) {
- if (item.getStatus() != FileItem.Status.IN_PROGRESS) {
- toDelete.add(item);
- }
- }
- for (FileItem item : toDelete) {
+ private void processClearAllAction(FacesContext context,UIFileUpload fileUpload) {
+ FileItem item = null;
+ while ((item = fileUpload.getFileForClean()) != null) {
fileUpload.getFileItems().remove(item);
}
+ putResponseData(context, getResponseData(fileUpload, null));
}
@@ -330,46 +290,28 @@
private void processNextAction(FacesContext context,
UIFileUpload fileUpload) {
- if (UIFileUpload.UPLOADING.equals(fileUpload.getUploadStatus())) {
- Iterator<FileItem> it = fileUpload.getFileItems().iterator();
- boolean found = false;
- while (it.hasNext()) {
- FileItem item = it.next();
- if (item.getStatus() == FileItem.Status.MARKED_4_UPLOAD) {
- item.setStatus(FileItem.Status.IN_PROGRESS);
- fileUpload.setUploadStatus(UIFileUpload.UNDER_UPLOAD);
- getSession(context).setAttribute(_percentBeanName, 0);
- found = true;
- break;
- }
- }
- if (!found) fileUpload.setUploadStatus(UIFileUpload.READY);
+ FileItem item = fileUpload.getFileByStatus(FileItem.Status.MARKED_4_UPLOAD);
+ if (item != null) {
+ item.setStatus(FileItem.Status.IN_PROGRESS);
+ setupSessionAttributes(context, fileUpload);
+ putResponseData(context, getResponseData(fileUpload, item.getFullFileName()));
+ }else {
+ tearDownSessionAttributes(context, fileUpload);
+ putResponseData(context, getResponseData(fileUpload, null));
}
}
private void processUploadAllAction(FacesContext context,
UIFileUpload fileUpload) {
- if (UIFileUpload.READY.equals(fileUpload.getUploadStatus())) {
-
- Iterator<FileItem> it = fileUpload.getFileItems().iterator();
- FileItem toUpload = null;
- while (it.hasNext()) {
- FileItem item = it.next();
- if (item.getStatus() == FileItem.Status.ADDED) {
- item.setStatus(FileItem.Status.MARKED_4_UPLOAD);
- if (toUpload == null) {
- toUpload = item;
- }
- }
- }
-
+ fileUpload.markForUpload();
+ FileItem toUpload = fileUpload.getFileByStatus(FileItem.Status.MARKED_4_UPLOAD);
if (toUpload != null) {
toUpload.setStatus(FileItem.Status.IN_PROGRESS);
- fileUpload.setUploadStatus(UIFileUpload.UNDER_UPLOAD);
- getSession(context).setAttribute(_percentBeanName, 0);
+ putResponseData(context, getResponseData(fileUpload, toUpload.getFullFileName()));
+ setupSessionAttributes(context, fileUpload);
+ }else {
+ putResponseData(context, getResponseData(fileUpload, null));
}
-
- }
}
private void processAddFileAction(FacesContext context,
@@ -380,9 +322,30 @@
FileItem fileItem = new FileItem(filename);
fileUpload.getFileItems().add(fileItem);
}
+ putResponseData(context, getResponseData(fileUpload, null));
}
}
-
+
+ private void putResponseData(FacesContext context, Object data) {
+ AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(context);
+ ajaxContext.setResponseData(data);
+ }
+
+ private Object getResponseData(UIFileUpload fileUpload, String fileName) {
+ Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> upload = new HashMap<String, Object>();
+ map.put("add", !fileUpload.isCanAdd());
+ boolean hasFilesInProgress = fileUpload.hasFilesInProgress();
+ upload.put("iscancel", hasFilesInProgress);
+ upload.put("disabled", (hasFilesInProgress) ? false :
!fileUpload.isCanUploadAll());
+ map.put("upload",upload);
+ map.put("clean", !fileUpload.isCanCleanAll());
+ if (fileName != null) {
+ map.put("filename", fileName);
+ }
+ return map;
+ }
+
private String getActionParameterName(String clientId) {
return clientId + "_action";
}
@@ -394,11 +357,11 @@
return null;
}
- public void encodeDate(FacesContext context, UIComponent component)
- throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- writer.write(new Date().toString());
- }
+// public void encodeDate(FacesContext context, UIComponent component)
+// throws IOException {
+// ResponseWriter writer = context.getResponseWriter();
+// writer.write(new Date().toString());
+// }
public String convertFileName(String name) {
return name.replaceAll("[\\\\]{1}", "\\\\\\\\");
@@ -424,11 +387,7 @@
script.append(containerId).append("','");
script.append(formId).append("','");
- script.append(actionUrl).append("',");
- script.append(getUploadAllClick(context, component));
- script.append(",");
- script.append(getStopAllClick(context, component));
- script.append(",'");
+ script.append(actionUrl).append("','");
script.append(component.getAttributes().get("addStyle"));
script.append("','");
script.append(component.getAttributes().get("addStyleDisabled"));
@@ -458,40 +417,21 @@
StringBuffer buffer = new StringBuffer();
buffer.append(getJSScriptStart(cliendId));
- buffer.append(".updateUploadButton(").append(fileUpload.isUploading() ?
"true," : "false,")
- .append(fileUpload.hasChildren() ? "false" :
"true").append(");\n");
+ boolean hasFileInProgress = fileUpload.hasFilesInProgress();
+ buffer.append(".updateUploadButton(").append(hasFileInProgress)
+ .append(",")
+ .append(hasFileInProgress ? false : !fileUpload.isCanUploadAll())
+ .append(");\n");
- buffer.append(getJSScriptStart(cliendId)).append(".updateAddButton(false);\n");
+ buffer.append(getJSScriptStart(cliendId)).append(".updateAddButton(")
+ .append(!fileUpload.isCanAdd()).append(");\n");
buffer.append(getJSScriptStart(cliendId)).append(".updateCleanButton(")
- .append(fileUpload.hasChildren() ? "false" :
"true").append(");\n");
+ .append(!fileUpload.isCanCleanAll()).append(");\n");
+
writer.write(buffer.toString());
}
- public void encodeUploadScript(FacesContext context, UIComponent component)
- throws IOException {
- UIFileUpload fileUpload = (UIFileUpload) component;
- String cliendId = fileUpload.getClientId(context);
- Writer writer = context.getResponseWriter();
- boolean found = false;
- if (!UIFileUpload.UPLOADING.equals(fileUpload.getUploadStatus())) {
- List<FileItem> items = fileUpload.getFileItems();
- Iterator<FileItem> it = items.iterator();
- while (it.hasNext()) {
- FileItem item = it.next();
- if (item.getStatus() == FileItem.Status.IN_PROGRESS) {
- found = true;
- StringBuffer buffer = getJSScriptStart(cliendId);
- buffer.append(".upload('");
- buffer.append(convertFileName(item.getFullFileName()));
- buffer.append("');\n");
- writer.write(buffer.toString());
- fileUpload.setUploadStatus(UIFileUpload.UPLOADING);
- return; // Only one file can be in progress status
- }
- }
- }
- }
/**
* Finds an instance of MultipartRequest wrapped within a request or its
@@ -533,13 +473,18 @@
public void renderLabel(FacesContext context, UIComponent component,
FileItem item) throws IOException {
+ UIComponent label = getProgressLabel(component);
Writer writer = context.getResponseWriter();
if (item.getStatus() == FileItem.Status.UPLOADED) {
- writer.write("Done");
+ writer.write("<b>Done</b>");
} else if (item.getStatus() == FileItem.Status.IN_PROGRESS) {
- writer.write("In progress....");
+ if (label != null) {
+ renderChild(context, label);
+ }else {
+ writer.write("<b>In progress</b>");
+ }
} else if (item.getStatus() == FileItem.Status.CANCELLED) {
- writer.write("Cancelled");
+ writer.write("<b>Cancelled</b>");
}
}
@@ -555,24 +500,7 @@
return item.getStatus() != FileItem.Status.IN_PROGRESS;
}
-
- private UIComponent findProgressBar(UIComponent fileUpload) {
- UIComponent progressBar = null;
- for (UIComponent child : fileUpload.getChildren()) {
- if (child instanceof UIFileUpload) {
- progressBar = child;
- break;
- }
- }
- return progressBar;
- }
-
- private void addComponentToReRender(FacesContext context,
- UIComponent component) {
- AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(context);
- ajaxContext.addComponentToAjaxRender(component);
- }
-
+
private UIComponent createProgressBar(FacesContext context,
UIComponent fileUpload) {
UIComponent progressBar = fileUpload.getFacet("progress");
@@ -597,6 +525,9 @@
progressBar.setValueExpression("value", ex);
progressBar.setId("progressBar");
progressBar.setTransient(false);
+ if (getProgressLabel(component) != null) {
+ progressBar.getAttributes().put("reRender", "progressLabel");
+ }
return progressBar;
}
@@ -607,136 +538,16 @@
return buffer;
}
- public String getControlLabel (FacesContext context, UIComponent component) {
- UIFileUpload fileUpload = (UIFileUpload) component;
- return (UIFileUpload.READY.equals(fileUpload.getUploadStatus()) ? "Upload" :
"Cancel");
- }
-
- public JSFunctionDefinition getUploadAllClick(FacesContext context, UIComponent
component) {
- String clientId = component.getClientId(context);
- JSFunctionDefinition definition = new JSFunctionDefinition();
- StringBuffer script = new StringBuffer();
- UIFileUpload fileUpload = (UIFileUpload) component;
- if (UIFileUpload.READY.equals(fileUpload.getUploadStatus())) {
- Map parameters = new HashMap();
- parameters.put(getActionParameterName(clientId), ACTION_UPLOAD_ALL);
- script.append(getOnClick(context, component, clientId, parameters,
- null));
- definition.addToBody(script);
+ private UIComponent getProgressLabel(UIComponent component) {
+ UIComponent label = component.getFacet("progressLabel");
+ if (label != null) {
+ label.setId("progressLabel");
}
- return definition;
+ return label;
}
- public String getUploadAllStyle(UIComponent component) {
- UIFileUpload fileUpload = (UIFileUpload) component;
- if (fileUpload.isReady()) {
- return (String) component.getAttributes().get("uploadStyle");
- }
- return "";
- }
-
- public String getUploadAllDisabled (UIComponent component) {
- UIFileUpload fileUpload = (UIFileUpload) component;
- return fileUpload.hasChildren() ? "false" : "true";
- }
-
- public JSFunctionDefinition getStopAllClick(FacesContext context, UIComponent
component) {
- String clientId = component.getClientId(context);
- JSFunctionDefinition definition = new JSFunctionDefinition();
- ComponentVariables variables = ComponentsVariableResolver.getVariables(
- this, component);
- Map parameters = new HashMap();
- parameters.put(getActionParameterName(clientId), ACTION_STOP_ALL);
- definition.addToBody(getOnClick(context, component, clientId, parameters, null));
- return definition;
- }
-
- public String getStopFileClick(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- ComponentVariables variables = ComponentsVariableResolver.getVariables(
- this, component);
- String fileName = (String) variables.getVariable("fullFileName");
- Map parameters = new HashMap();
- parameters.put(getActionParameterName(clientId), ACTION_STOP_FILE);
- parameters.put(ACTION_STOP_FILE, fileName);
- return getOnClick(context, component, clientId, parameters, null);
- }
-
- public String getClearFileClick(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- StringBuffer buffer = new StringBuffer();
- ComponentVariables variables = ComponentsVariableResolver.getVariables(
- this, component);
- String fileName = (String) variables.getVariable("fullFileName");
-
- StringBuffer body = getJSScriptStart(clientId)
- .append(".clear('")
- .append(convertFileName(fileName))
- .append("');");
-
- Object oncomplete = getOnComplete(context, component, body);
- Map parameters = new HashMap();
- parameters.put(getActionParameterName(clientId), ACTION_CLEAR_FILE);
- parameters.put(ACTION_CLEAR_FILE, fileName);
-
- return getOnClick(context, component, clientId, parameters, oncomplete);
-
- }
-
- public String getClearAllClick(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- StringBuffer body = getJSScriptStart(clientId)
- .append(".clearAll();");
- Object oncomplete = getOnComplete(context, component, body);
- Map parameters = new HashMap();
- parameters.put(getActionParameterName(clientId), ACTION_CLEAR_ALL);
-
- return getOnClick(context, component, clientId, parameters, oncomplete);
- }
-
- public String getAddFileClick(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
-
- StringBuffer body = getJSScriptStart(clientId)
- .append(".addFile();");
- Object oncomplete = getOnComplete(context, component, body);
- Map parameters = new HashMap();
- parameters.put(getActionParameterName(clientId), ACTION_ADD_FILE);
-
- return getOnClick(context, component, clientId, parameters, oncomplete);
-
- }
-
- private String getOnClick(FacesContext context, UIComponent component,
- String clientId, Map parameters, Object oncomplete) {
- StringBuffer script = new StringBuffer();
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
- context);
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
-
- Map p = (Map) options.get("parameters");
- p.putAll(parameters);
-
- if (oncomplete != null) {
- options.put("oncomplete", oncomplete);
- }
-
- function.addParameter(options);
- function.appendScript(script);
- return script.toString();
- }
-
- private JSFunctionDefinition getOnComplete(FacesContext context,
- UIComponent component, Object body) {
- JSFunctionDefinition oncomplete = new JSFunctionDefinition();
- oncomplete.addParameter("request");
- oncomplete.addParameter("event");
- oncomplete.addParameter("data");
- oncomplete.addToBody(body);
- return oncomplete;
- }
-
- /*
+
+ /*
* (non-Javadoc)
*
* @see
org.richfaces.renderkit.TemplateEncoderRendererBase#encodeChildren(javax.faces.context.FacesContext,
Modified:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartFilter.java
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartFilter.java 2008-02-09
03:48:17 UTC (rev 5975)
+++
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartFilter.java 2008-02-09
15:13:38 UTC (rev 5976)
@@ -69,7 +69,6 @@
HttpServletRequest httpRequest = (HttpServletRequest) request;
if (isMultipartRequest(httpRequest))
{
- System.out.println("Request content length" +
httpRequest.getContentLength());
chain.doFilter(new MultipartRequest(httpRequest, createTempFiles,
maxRequestSize), response);
}
Modified:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java 2008-02-09
03:48:17 UTC (rev 5975)
+++
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java 2008-02-09
15:13:38 UTC (rev 5976)
@@ -12,6 +12,7 @@
import java.rmi.server.UID;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
@@ -22,6 +23,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
+import org.richfaces.org.jboss.seam.ui.component.ProgressData;
import org.richfaces.org.jboss.seam.ui.renderkit.FileUploadRendererBase;
/**
@@ -235,6 +237,10 @@
}
private HttpServletRequest request;
+
+ private long time;
+
+ private ProgressData progressData = null;
public MultipartRequest(HttpServletRequest request,
boolean createTempFiles, int maxRequestSize) {
@@ -244,6 +250,7 @@
String contentLength = request.getHeader("Content-Length");
this.contentLength = Integer.parseInt(contentLength);
+ initProgressInfo(this.contentLength);
if (contentLength != null && maxRequestSize > 0
&& this.contentLength > maxRequestSize) {
throw new FileUploadException(
@@ -399,8 +406,7 @@
}
this.read += pos;
pos = 0;
- getSession().setAttribute(FileUploadRendererBase._percentBeanName,
- (Double) (100.0 * this.read / this.contentLength));
+ fillProgressInfo();
}
} catch (IOException ex) {
@@ -408,7 +414,36 @@
ex);
}
}
+
+ private ProgressData getProgressData () {
+ ProgressData progressData = null;
+ String beanName =
(String)getSession().getAttribute(FileUploadRendererBase._progressInfoBeanName);
+ if (beanName != null) {
+ progressData = (ProgressData)getSession().getAttribute(beanName);
+ }
+ return progressData;
+ }
+
+ private void fillProgressInfo () {
+ Double percent = (Double) (100.0 * this.read / this.contentLength);
+ getSession().setAttribute(FileUploadRendererBase._percentBeanName,percent);
+ if (this.progressData != null) {
+ progressData.setPercent(percent);
+ progressData.setUploaded((long)this.read);
+ progressData.setTime((new Date().getTime() / 1000)- this.time);
+ }
+ }
+
+ private void initProgressInfo(int size) {
+ time = new Date().getTime()/1000;
+ progressData = getProgressData();
+ if (progressData != null) {
+ progressData.setSize((long)size);
+ progressData.setTime(0L);
+ }
+ }
+
private byte[] getBoundaryMarker(String contentType) {
Map<String, Object> params = parseParams(contentType, ";");
String boundaryStr = (String) params.get("boundary");
Modified:
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-02-09
03:48:17 UTC (rev 5975)
+++
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-02-09
15:13:38 UTC (rev 5976)
@@ -2,7 +2,7 @@
FileUpload = Class.create();
FileUpload.Uploaders = {};
Object.extend(FileUpload.prototype, {
- initialize: function(id, containerId, formId, actionUrl, onUploadAllClick ,
onStopAllClick, addStyle, addStyleDisabled, uploadStyle, uploadStyleDisabled, cancelStyle,
cancelStyleDisabled, cleanStyle, cleanStyleDisabled) {
+ initialize: function(id, containerId, formId, actionUrl, addStyle, addStyleDisabled,
uploadStyle, uploadStyleDisabled, cancelStyle, cancelStyleDisabled, cleanStyle,
cleanStyleDisabled) {
this.id = id;
this.containerId = containerId;
this.formId = formId;
@@ -11,8 +11,6 @@
this.f = $(id + ":files");
this.fm = $(id + ":f");
this.fr = $(id + ":fr");
- this.onUploadAllClick = function () { onUploadAllClick(); }
- this.onStopAllClick = function () { onStopAllClick(); }
this.addStyle = addStyle;
this.addStyleDisabled = addStyleDisabled;
this.uploadStyle = uploadStyle;
@@ -21,6 +19,9 @@
this.cancelStyleDisabled = cancelStyleDisabled;
this.cleanStyle = cleanStyle;
this.cleanStyleDisabled = cleanStyleDisabled;
+ this.canAddAll = true;
+ this.canUploadAll = false;
+ this.canCleanAll = false;
$(this.id).component = this;
},
renderControl: function (template, context) {
@@ -34,12 +35,15 @@
o.className = className;
},
updateCleanButton: function(disabled) {
+ this.canCleanAll = !disabled;
this.updateButton($(this.id+":clean1"),$(this.id+":clean2"),this.cleanStyle,this.cleanStyleDisabled,"clear",disabled);
},
updateAddButton: function(disabled) {
+ this.canAddAll = !disabled;
this.updateButton($(this.id+":add1"),$(this.id+":add2"),this.addStyle,this.addStyleDisabled,"add",disabled);
},
updateUploadButton: function (isCancel, disabled) {
+ this.canUploadAll = !disabled;
var d = $(this.id + ":upload1");
var l = $(this.id + ":upload2");
if (d && l) {
@@ -47,11 +51,11 @@
if (isCancel) {
l.innerHTML = label;
this.updateButton(d,l,this.cancelStyle,this.cancelStyleDisabled,"start",disabled);
- d.onclick = function () { if (this.getFilesCount() > 0) { event = null;
this.stopAll(); this.onStopAllClick(); } }.bind(this);
+ d.onclick = function () { this.stopAll(); }.bind(this);
}else {
l.innerHTML = label;
this.updateButton(d,l,this.uploadStyle,this.uploadStyleDisabled,"start",disabled);
- d.onclick = function () { if (this.getFilesCount() > 0) { event = null;
this.onUploadAllClick(); } }.bind(this);
+ d.onclick = function () { this.uploadAll(); }.bind(this);
}
}
@@ -65,11 +69,47 @@
this.setClassName(o2, "upload_button_content upload_font upload_ico
upload_ico_"+prefix+" "+style);
}
},
- init: function (id) {
- this.id = id;
- this.createForm();
- },
- addFile: function (disabled){
+ processResponseData: function (data) {
+ if (data) {
+ var add = data['add'];
+ if (add != null) {
+ this.updateAddButton(add);
+ }
+ var upload = data['upload'];
+ this.updateUploadButton(upload['iscancel'],upload['disabled']);
+ var clean = data['clean'];
+ if (clean != null) {
+ this.updateCleanButton(clean);
+ }
+ }
+ },
+ sendAjaxRequest: function (params, oncomplete) {
+ var options = {};
+ options['actionUrl'] = this.actionUrl;
+ var p = options['parameters'] = {};
+ p[this.id] = this.id;
+ if (params) {
+ for (var param in params) {
+ p[param] = params[param];
+ }
+ }
+ if (oncomplete) {
+ options['oncomplete'] = oncomplete;
+ }
+ A4J.AJAX.Submit(this.containerId,this.formId,null,options);
+ },
+ add: function () {
+ if (!this.canAddAll) return;
+ var oncomplete = function(request, event, data) {
+ this._add();
+ this.processResponseData(data);
+ }.bind(this);
+ var params = {};
+ params[this.id + "_action"] = 'add';
+ this.sendAjaxRequest(params, oncomplete);
+ return false;
+ },
+ _add: function (){
var o = $(this.id + ":file");
var parent = o.parentNode;
@@ -95,7 +135,21 @@
this.fm.appendChild(d);
}
},
- upload: function (name) {
+ uploadAll: function () {
+ if (!this.canUploadAll) return;
+ if (this.getFilesCount() == 0) return;
+ var oncomplete = function(request, event, data) {
+ this.processResponseData(data);
+ if (data['filename']) {
+ this._upload(data['filename']);
+ }
+ }.bind(this);
+ var params = {};
+ params[this.id + "_action"] = 'uploadall';
+ this.sendAjaxRequest(params, oncomplete);
+ return false;
+ },
+ _upload: function (name) {
var v = this.findFileByName(name);
this.addViewState();
this.prepareUpload();
@@ -107,10 +161,15 @@
}
},
next: function (ev) {
- var f = {};
- f[this.id] = this.id;
- f[this.id + "_action"] = "next";
- A4J.AJAX.Submit(this.containerId,this.formId,ev,{'parameters':f
,'actionUrl':this.actionUrl} );
+ var params = {};
+ params[this.id + "_action"] = "next";
+ var oncomplete = function(request, event, data) {
+ this.processResponseData(data);
+ if (data['filename']) {
+ this._upload(data['filename']);
+ }
+ }.bind(this);
+ this.sendAjaxRequest(params, oncomplete);
},
onFileUploaded: function (ev) {
var d = $(this.id).component;
@@ -145,8 +204,7 @@
this.onFileUploaded(event);
}.bind(this);
- //new Function ("event"," var f = new
FileUpload('"+this.id+"'); if (f.getFilesCount() == 0) return;
f.onFileUploaded(event);");
-
+
document.body.appendChild(fr);
var f = document.createElement("form");
@@ -176,23 +234,53 @@
}
return 0;
},
- clearAll: function() {
+ cleanAll: function () {
+ if (!this.canCleanAll) return;
+ var params = {}
+ params[this.id + "_action"] = "clearall";
+ var oncomplete = function (request, event, data) {
+ this.processResponseData(data);
+ this._cleanAll();
+ }.bind(this);
+ this.sendAjaxRequest(params, oncomplete);
+ return false;
+ },
+ _cleanAll: function() {
this.removeChilds(this.f);
},
+ stopRequest: function () {
+ this.canceled = true;
+ this.fr.src = "about:blank";
+ },
stop: function () {
- this.canceled = true;
$(this.formId+":progressBar").component.disable();
- var fr = $(this.id + ":fr");
- fr.src = "about:blank";
+ this.stopRequest();
var f = $(this.id + ":1");
if (f) {
f.disabled = true;
f.id = "add";
f.name = f.id;
- }
+ }
+ var params = {}
+ params[this.id + "_action"] = "stop";
+ var oncomplete = function (request, event, data) {
+ this.processResponseData(data);
+ if (data['filename']) {
+ this._upload(data['filename']);
+ }
+ }.bind(this);
+ this.sendAjaxRequest(params, oncomplete);
+ return false;
},
stopAll: function () {
- this.stop();
+ this.stopRequest();
+ var params = {}
+ params[this.id + "_action"] = "stopall";
+ var oncomplete = function (request, event, data) {
+ this.processResponseData(data);
+ }.bind(this);
+ this.sendAjaxRequest(params, oncomplete);
+ return false;
},
prepareUpload: function () {
for (var i = 0; i < this.f.childNodes.length; i++) {
@@ -231,10 +319,19 @@
return null;
},
clear: function (name) {
- if (this.getFilesCount() == 0) {
- return;
- }
var v = this.findFileByName(name);
+ if (!v) return;
+ var params = {}
+ params[this.id + "_action"] = "clear";
+ params["clear"] = name;
+ var oncomplete = function (request, event, data) {
+ this.processResponseData(data);
+ this._clear(v);
+ }.bind(this);
+ this.sendAjaxRequest(params, oncomplete);
+ return false;
+ },
+ _clear: function (v) {
if (v) {
this.f.removeChild(v);
}
Modified: trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-02-09
03:48:17 UTC (rev 5975)
+++
trunk/sandbox/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-02-09
15:13:38 UTC (rev 5976)
@@ -34,24 +34,25 @@
<tr>
<td>
<div class="upload_button_border" style=" float:left;">
- <div class="upload_button upload_font
#{component.attributes['addStyle']}"
onmouseover="this.className='upload_button_light upload_font'"
onmousedown="this.className='upload_button_press upload_font'"
onmouseup="this.className='upload_button upload_font'"
onmouseout="this.className='upload_button upload_font'"
+ <div class="upload_button upload_font"
onmouseover="this.className='upload_button_light upload_font'"
onmousedown="this.className='upload_button_press upload_font'"
onmouseup="this.className='upload_button upload_font'"
onmouseout="this.className='upload_button upload_font'"
style="position: relative; overflow: hidden; direction: rtl;
width:70px"
id="#{clientId}:add1">
- <div class="upload_button_content upload_font upload_ico upload_ico_add
#{component.attributes['addStyle']}"
+ <div class="upload_button_content upload_font upload_ico
upload_ico_add"
id="#{clientId}:add2">Add...</div>
<input type="file" style="cursor: pointer; z-index: 3; width:
0px; height: 22px; left: 0px; top: 0px; position: absolute"
class="hidden"
id="#{clientId}:file"
name="fileName"
- onchange="#{this:getAddFileClick(context,component)}; return
false;"/>
+ onchange="return $('#{clientId}').component.add();"/>
</div>
</div>
<div class="upload_button_border" style=" float:left;">
- <div class="upload_button_dis upload_font
#{component.attributes['uploadStyleDisabled']}"
onmouseover="this.className='upload_button_light upload_font'"
onmousedown="this.className='upload_button_press upload_font'"
onmouseup="this.className='upload_button upload_font'"
+ <div class="upload_button upload_font"
onmouseover="this.className='upload_button_light upload_font'"
onmousedown="this.className='upload_button_press upload_font'"
onmouseup="this.className='upload_button upload_font'"
onmouseout="this.className='upload_button upload_font'"
- id="#{clientId}:upload1">
+ id="#{clientId}:upload1"
+ onclick="return $('#{clientId}').component.uploadAll();">
<a href="#" class="upload_button_selection">
- <div class="upload_button_content upload_font upload_ico
upload_ico_start_dis #{component.attributes['uploadStyleDisabled']}"
+ <div class="upload_button_content upload_font upload_ico
upload_ico_start"
id="#{clientId}:upload2">
<b>Upload</b>
</div>
@@ -59,12 +60,12 @@
</div>
</div>
<div class="upload_button_border" style=" float:right">
- <div class="upload_button_dis upload_font
#{component.attributes['cleanStyleDisabled']}"
onmouseover="this.className='upload_button_light upload_font'"
onmousedown="this.className='upload_button_press upload_font'"
onmouseup="this.className='upload_button upload_font'"
+ <div class="upload_button upload_font"
onmouseover="this.className='upload_button_light upload_font'"
onmousedown="this.className='upload_button_press upload_font'"
onmouseup="this.className='upload_button upload_font'"
onmouseout="this.className='upload_button upload_font'"
- onclick="if ($('#{clientId}').component.getFilesCount() > 0) {
#{this:getClearAllClick(context, component)} }"
+ onclick="return $('#{clientId}').component.cleanAll();"
id="#{clientId}:clean1">
<a href="#" class="upload_button_selection">
- <div class="upload_button_content upload_font upload_ico
upload_ico_clear_dis #{component.attributes['cleanStyleDisabled']}"
+ <div class="upload_button_content upload_font upload_ico
upload_ico_clear"
id="#{clientId}:clean2">Clean All</div>
</a>
</div>
@@ -85,6 +86,7 @@
String fileName = item.getFileName();
variables.setVariable("fileName",fileName);
variables.setVariable("fullFileName",fullFileName);
+ variables.setVariable("fullFileNameJs",convertFileName(fullFileName));
variables.setVariable("n",i);
]]>
</jsp:scriptlet>
@@ -104,13 +106,11 @@
<div class="upload_name_padding">
- <b>
<jsp:scriptlet>
<![CDATA[
renderLabel(context, component, item);
]]>
</jsp:scriptlet>
- </b>
</div>
@@ -126,7 +126,7 @@
onclick="return
$('#{clientId}').component.confirm('#{clientId}:cconfirm#{n}','#{clientId}:clear#{n}');"
style="text-decoration: none; color:black">Clear</a>
<span id="#{clientId}:cconfirm#{n}"
style="display:none">
- <a href="#" onclick="#{this:getClearFileClick(context,
component)}" style="text-decoration: none; color:black">Yes</a>
+ <a href="#" onclick="return
$('#{clientId}').component.clear('#{fullFileNameJs}');"
style="text-decoration: none; color:black">Yes</a>
<a href="#"
onclick="$('#{clientId}').component.reduce('#{clientId}:cconfirm#{n}','#{clientId}:clear#{n}');"
style="text-decoration: none; padding-left: 10px; color:black">No</a>
</span>
</div>
@@ -140,7 +140,7 @@
onclick="return
$('#{clientId}').component.confirm('#{clientId}:sconfirm#{n}','#{clientId}:stop#{n}');"
style="text-decoration: none; color:black">Stop</a>
<span id="#{clientId}:sconfirm#{n}"
style="display:none">
- <a href="#" onclick="$('#{clientId}').component.stop();
#{this:getStopFileClick(context, component)}" style="text-decoration: none;
color:black">Yes</a>
+ <a href="#" onclick="return
$('#{clientId}').component.stop();" style="text-decoration: none;
color:black">Yes</a>
<a href="#"
onclick="$('#{clientId}').component.reduce('#{clientId}:sconfirm#{n}','#{clientId}:stop#{n}');"
style="text-decoration: none; padding-left: 10px; color:black">No</a>
</span>
</div>
@@ -164,14 +164,12 @@
]]>
</jsp:scriptlet>
- <span>
- <script type="text/javascript">
- <f:call name="encodeUpdateButtonScript" />
- <f:call name="encodeUploadScript" />
- </script>
- </span>
-
</div>
+ <span>
+ <script type="text/javascript">
+ <f:call name="encodeUpdateButtonScript" />
+ </script>
+ </span>
</div>