JBoss Rich Faces SVN: r5976 - in trunk/sandbox/ui/fileUpload/src/main: java/org/richfaces/org/jboss/seam/ui/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
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>
18 years, 2 months
JBoss Rich Faces SVN: r5975 - in trunk/ui/modal-panel/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 22:48:17 -0500 (Fri, 08 Feb 2008)
New Revision: 5975
Modified:
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2150
Modified: trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
===================================================================
--- trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2008-02-09 03:48:12 UTC (rev 5974)
+++ trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2008-02-09 03:48:17 UTC (rev 5975)
@@ -24,17 +24,15 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.component.UIModalPanel;
/**
@@ -160,4 +158,5 @@
public void writeEventHandlerFunction(FacesContext context, UIComponent component, String eventName) throws IOException{
RendererUtils.writeEventHandlerFunction(context, component, eventName);
}
+
}
Modified: trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
--- trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-02-09 03:48:12 UTC (rev 5974)
+++ trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-02-09 03:48:17 UTC (rev 5975)
@@ -561,12 +561,10 @@
var cw = getSizeElement().clientWidth;
if (RichFaces.navigatorType() == RichFaces.OPERA)
{
- _left = (cw - eContentDiv.parentNode.getWidth()) / 2;
+ _left = (cw - eContentDiv.getWidth()) / 2;
}
else {
- var _width = Richfaces.getComputedStyleSize(eContentDiv.parentNode, "width");
- if (isNaN(_width))
- _width = eContentDiv.parentNode.clientWidth;
+ var _width = eContentDiv.clientWidth;
_left = (cw - _width) / 2;
}
@@ -583,12 +581,10 @@
var cw = getSizeElement().clientHeight;
if (RichFaces.navigatorType() == RichFaces.OPERA)
{
- _top = (cw - eContentDiv.parentNode.getHeight()) / 2;
+ _top = (cw - eContentDiv.getHeight()) / 2;
}
else {
- var _height = Richfaces.getComputedStyleSize(eContentDiv.parentNode, "height");
- if (isNaN(_height))
- _height = eContentDiv.parentNode.clientHeight;
+ var _height = eContentDiv.clientHeight;
_top = (cw - _height) / 2;
}
}
@@ -954,7 +950,7 @@
}
}
-Richfaces.showModalPanel = function (id, opts, event) {
+Richfaces._showModalPanel = function (id, opts, event, sync) {
var invoke =
(RichFaces.MSIE == RichFaces.navigatorType()) ?
@@ -979,12 +975,25 @@
panel = Richfaces.findModalPanel(id);
}
invoke(function() {
- panel.component.show(event, opts);
+ if (sync) {
+ panel.component.syncShow(event, opts);
+ } else {
+ panel.component.show(event, opts);
+ }
});
};
+Richfaces.showModalPanel = function (id, opts, event) {
+ Richfaces._showModalPanel(id, opts, event, false);
+};
+
+Richfaces.syncShowModalPanel = function (id, opts, event) {
+ Richfaces._showModalPanel(id, opts, event, true);
+};
+
+
Richfaces.hideModalPanel = function (id, opts, event) {
var panel = $(id);
if (!panel) {
Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2008-02-09 03:48:12 UTC (rev 5974)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2008-02-09 03:48:17 UTC (rev 5975)
@@ -81,10 +81,39 @@
<div id="#{clientId}ShadowDiv" class="dr-mpnl-shadow rich-mpnl-shadow"
style="#{component.shadowStyle}" >
</div>
-
- <div id="#{clientId}ContentDiv" style="position: absolute; z-index: 2; overflow: hidden; width: #{component.minWidth}px; height: #{component.minHeight}px; #{component.attributes['style']}" class="dr-mpnl-pnl rich-mp-content">
+
+ <c:object var="divStyle" type="java.lang.String" />
+ <c:object var="tableStyle" type="java.lang.String" />
+
+ <jsp:scriptlet>
+ <![CDATA[
+ if (component.isAutosized()) {
+ int minWidth = component.getMinWidth();
+ int minHeight = component.getMinHeight();
+
+ int width = component.getWidth();
+ int height = component.getHeight();
+
+ if (width < 0 || width < minWidth) {
+ width = minWidth;
+ }
+
+ if (height < 0 || height < minHeight) {
+ height = minHeight;
+ }
+
+ tableStyle += "width: " + (width > 0 ? width : 1) + "px;";
+ tableStyle += "height: " + (height > 0 ? height : 1) + "px;";
+
+ } else {
+ tableStyle = "height: 100%; width: 100%;";
+ }
+ ]]>
+ </jsp:scriptlet>
+
+ <div id="#{clientId}ContentDiv" style="position: absolute; z-index: 2; overflow: hidden; #{component.attributes['style']}" class="dr-mpnl-pnl rich-mp-content">
- <table style="height: 100%; width: 100%;" border="0" cellpadding="0" cellspacing="0">
+ <table style="#{tableStyle}" border="0" cellpadding="0" cellspacing="0">
<jsp:scriptlet>
<![CDATA[if(component.getFacet("header")!=null && component.getFacet("header").isRendered()) {]]>
</jsp:scriptlet>
18 years, 2 months
JBoss Rich Faces SVN: r5974 - trunk/samples/modalpanel-sample/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 22:48:12 -0500 (Fri, 08 Feb 2008)
New Revision: 5974
Modified:
trunk/samples/modalpanel-sample/src/main/webapp/pages/index.jsp
Log:
http://jira.jboss.com/jira/browse/RF-2150
Modified: trunk/samples/modalpanel-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/modalpanel-sample/src/main/webapp/pages/index.jsp 2008-02-09 02:29:48 UTC (rev 5973)
+++ trunk/samples/modalpanel-sample/src/main/webapp/pages/index.jsp 2008-02-09 03:48:12 UTC (rev 5974)
@@ -144,6 +144,7 @@
</mp:modalPanel>
<f:verbatim>
<a href="javascript:$('_form:_panel').component.syncShow();">Synchronous Show</a>
+ <a href="javascript:Richfaces.syncShowModalPanel(':_panel');">Synchronous Show 2</a>
<a href="javascript:Richfaces.showModalPanel(':_panel');">Show</a>
<a href="javascript:Richfaces.showModalPanel(':_panel', {left: '120', top: 'auto'});">Show: left = 120; top = auto</a>
<a href="javascript:Richfaces.showModalPanel(':_panel', {top: 'auto', width: 800});">Show: width = 800; top = auto</a>
@@ -152,7 +153,7 @@
</f:verbatim>
- <mp:modalPanel id="eventInfoID" autosized="true" minHeight="550" minWidth="400" moveable="true" style="overflow: true;">
+ <mp:modalPanel id="eventInfoID" autosized="true" minHeight="250" minWidth="200" moveable="true" style="overflow: true;">
<f:facet name="header">
<h:outputText value="Events..." />
</f:facet>
@@ -162,7 +163,7 @@
</f:facet>
- <h:outputText value="Eventsaaaaaaaaaaaaaaaa ..." />
+ <h:outputText value="Eventsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ..." />
</mp:modalPanel>
</h:panelGrid>
18 years, 2 months
JBoss Rich Faces SVN: r5973 - in trunk/samples: seamEAR/ejbs and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 21:29:48 -0500 (Fri, 08 Feb 2008)
New Revision: 5973
Modified:
trunk/samples/seamEAR/ear/
trunk/samples/seamEAR/ejbs/
trunk/samples/seamEAR/primary-source/
trunk/samples/seamEAR/projects/logging/
trunk/samples/seamEAR/wars/seamWebapp/
trunk/samples/seamPortletEar/seamBookingPortlet/
Log:
service files svn:ignored
Property changes on: trunk/samples/seamEAR/ear
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: trunk/samples/seamEAR/ejbs
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: trunk/samples/seamEAR/primary-source
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: trunk/samples/seamEAR/projects/logging
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: trunk/samples/seamEAR/wars/seamWebapp
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: trunk/samples/seamPortletEar/seamBookingPortlet
___________________________________________________________________
Name: svn:ignore
+ target
18 years, 2 months
JBoss Rich Faces SVN: r5972 - trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 21:20:48 -0500 (Fri, 08 Feb 2008)
New Revision: 5972
Modified:
trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
Log:
http://jira.jboss.com/jira/browse/RF-1696
Modified: trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
===================================================================
--- trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss 2008-02-09 02:00:25 UTC (rev 5971)
+++ trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss 2008-02-09 02:20:48 UTC (rev 5972)
@@ -7,54 +7,50 @@
<f:verbatim>
-body{margin : 20px}
-*{font-family : verdana; font-size : 11px}
-
-.rich-progress-bar-height{height : 13px;}
-.rich-progress-bar-width{width : 200px}
-.rich-progress-bar-block{white-space : nowrap;}
-.rich-progress-bar-uploaded{background-repeat : repeat-x;}
-.rich-progress-bar-uploaded-dig{overflow : hidden; position : absolute; top : 0px; left : 0px;}
-.rich-progress-bar-shell{margin-bottom : 2px; border : 1px solid;}
-.rich-progress-bar-shell-dig{position : relative; margin-bottom : 2px; border : 1px solid;}
-.rich-progress-bar-remained{text-align : center; font-weight : bold; position : relative;}
-.rich-progress-bar-completed{text-align : center; font-weight : bold; background-repeat : repeat-x;}
-.rich-progress-bar-padding{padding: 0px}
+ .rich-progress-bar-height{height : 13px;}
+ .rich-progress-bar-width{width : 200px}
+ .rich-progress-bar-block{white-space : nowrap;}
+ .rich-progress-bar-uploaded{background-repeat : repeat-x;}
+ .rich-progress-bar-uploaded-dig{overflow : hidden; position : absolute; top : 0px; left : 0px;}
+ .rich-progress-bar-shell{margin-bottom : 2px; border : 1px solid;}
+ .rich-progress-bar-shell-dig{position : relative; margin-bottom : 2px; border : 1px solid;}
+ .rich-progress-bar-remained{text-align : center; font-weight : bold; position : relative;}
+ .rich-progress-bar-completed{text-align : center; font-weight : bold; background-repeat : repeat-x;}
+ .rich-progress-bar-padding{padding: 0px}
</f:verbatim>
- <u:selector name=".rich-progress-bar-shell-dig">
- <u:style name="background-color" skin="controlBackgroundColor" />
- <u:style name="border-color" skin="panelBorderColor" />
+ <u:selector name=".rich-progress-bar-uploaded">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.ProgressBarAnimatedBg" />
+ </u:style>
+ <u:style name="background-color" skin="selectControlColor" />
+ </u:selector>
+
+ <u:selector name=".rich-progress-bar-shell">
+ <u:style name="background-color" skin="controlBackgroundColor" />
+ <u:style name="border-color" skin="panelBorderColor" />
</u:selector>
+ <u:selector name=".rich-progress-bar-uploaded-dig">
+ <u:style name="border-color" skin="panelBorderColor" />
+ </u:selector>
+
<u:selector name=".rich-progress-bar-shell-dig">
- <u:style name="border-color" skin="panelBorderColor" />
+ <u:style name="border-color" skin="panelBorderColor" />
</u:selector>
<u:selector name=".rich-progress-bar-remained">
- <u:style name="background-color" skin="controlBackgroundColor" />
- <u:style name="text-color" skin="controlTextColor" />
+ <u:style name="background-color" skin="controlBackgroundColor" />
+ <u:style name="text-color" skin="controlTextColor" />
</u:selector>
- <u:selector name=".rich-progress-bar-uploaded">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.ProgressBarAnimatedBg" />
- </u:style>
- <u:style name="background-color" skin="selectControlColor" />
- <u:style name="border-color" skin="panelBorderColor" />
+ <u:selector name=".rich-progress-bar-completed">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.ProgressBarAnimatedBg" />
+ </u:style>
+ <u:style name="background-color" skin="selectControlColor" />
+ <u:style name="text-color" skin="controlBackgroundColor" />
</u:selector>
-
- <u:selector name=".rich-progress-bar-uploaded-dig">
- <u:style name="border-color" skin="panelBorderColor" />
- </u:selector>
-
- <u:selector name=".rich-progress-bar-completed">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.ProgressBarAnimatedBg" />
- </u:style>
- <u:style name="background-color" skin="selectControlColor" />
- <u:style name="text-color" skin="controlBackgroundColor" />
- </u:selector>
</f:template>
\ No newline at end of file
18 years, 2 months
JBoss Rich Faces SVN: r5971 - in trunk: samples/progressBarDemo and 9 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 21:00:25 -0500 (Fri, 08 Feb 2008)
New Revision: 5971
Added:
trunk/samples/progressBarDemo/
trunk/samples/progressBarDemo/pom.xml
trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/
trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/Bean.java
trunk/samples/progressBarDemo/src/main/webapp/pages/index.jsp
trunk/ui/progressBAR/
trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
Removed:
trunk/samples/progressBarDemo/pom.xml
trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/Bean.java
trunk/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/
trunk/samples/progressBarDemo/src/main/webapp/pages/index.jsp
trunk/sandbox/samples/progressBarDemo/
trunk/sandbox/ui/progressBAR/
trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
Modified:
trunk/samples/pom.xml
trunk/samples/progressBarDemo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/progressBarDemo/src/main/webapp/pages/index.xhtml
trunk/sandbox/samples/pom.xml
trunk/sandbox/ui/pom.xml
trunk/ui/pom.xml
trunk/ui/progressBAR/pom.xml
Log:
ProgressBar component moved to main build
Modified: trunk/samples/pom.xml
===================================================================
--- trunk/samples/pom.xml 2008-02-09 01:14:34 UTC (rev 5970)
+++ trunk/samples/pom.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -462,6 +462,7 @@
<module>combobox-sample</module>
<module>pickList-sample</module>
+ <module>progressBarDemo</module>
</modules>
</project>
\ No newline at end of file
Copied: trunk/samples/progressBarDemo (from rev 5966, trunk/sandbox/samples/progressBarDemo)
Deleted: trunk/samples/progressBarDemo/pom.xml
===================================================================
--- trunk/sandbox/samples/progressBarDemo/pom.xml 2008-02-08 18:58:01 UTC (rev 5966)
+++ trunk/samples/progressBarDemo/pom.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -1,41 +0,0 @@
-<?xml version="1.0"?><project>
- <parent>
- <artifactId>samples</artifactId>
- <groupId>org.richfaces.sandbox</groupId>
- <version>3.2.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.sandbox.samples</groupId>
- <artifactId>progressBarDemo</artifactId>
- <packaging>war</packaging>
- <name>progressBarDemo Maven Webapp</name>
- <version>3.2.0-SNAPSHOT</version>
- <build>
- <finalName>progressBarDemo</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.richfaces.sandbox.ui</groupId>
- <artifactId>progressBar</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.richfaces.samples</groupId>
- <artifactId>skins</artifactId>
- <version>${project.version}</version>
- </dependency>
-
-
- </dependencies>
-</project>
\ No newline at end of file
Copied: trunk/samples/progressBarDemo/pom.xml (from rev 5969, trunk/sandbox/samples/progressBarDemo/pom.xml)
===================================================================
--- trunk/samples/progressBarDemo/pom.xml (rev 0)
+++ trunk/samples/progressBarDemo/pom.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<project>
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.samples</groupId>
+ <artifactId>progressBarDemo</artifactId>
+ <packaging>war</packaging>
+ <name>progressBarDemo Maven Webapp</name>
+ <build>
+ <finalName>progressBarDemo</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>progressBar</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>componentControl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.richfaces.samples</groupId>
+ <artifactId>skins</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ </dependencies>
+</project>
Copied: trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples (from rev 5966, trunk/sandbox/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/samples)
Deleted: trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/Bean.java
===================================================================
--- trunk/sandbox/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java 2008-02-08 18:58:01 UTC (rev 5966)
+++ trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/Bean.java 2008-02-09 02:00:25 UTC (rev 5971)
@@ -1,115 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.sandbox.samples;
-
-
-import java.util.Date;
-
-/**
- * @author $Autor$
- *
- */
-public class Bean {
-
- private boolean enabled = false;
- private boolean permanent = false;
- private boolean determined = true;
- private boolean ajaxMode;
-
- private Integer value = 0;
-
- public String action () {
- return null;
- }
-
- public String start() {
- this.enabled = true;
- return null;
- }
-
- public String getDate() {
- Date date = new Date();
- return date.toLocaleString();
- }
-
- /**
- * @return the value
- */
- public Integer getValue() {
- //value = value.add(new BigDecimal(0.6));
- return value;
- }
-
- /**
- * @param value the value to set
- */
- public void setValue(Integer value) {
- this.value = value;
- }
-
- public Integer getIncValue() {
- return value++;
- }
-
- /**
- * @return the enabled
- */
- public boolean getEnabled() {
- return enabled;
- }
-
- /**
- * @param enabled the enabled to set
- */
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public boolean isPermanent() {
- return permanent;
- }
-
- public void setPermanent(boolean permanent) {
- this.permanent = permanent;
- }
-
- public boolean isDetermined() {
- return determined;
- }
-
- public void setDetermined(boolean determined) {
- this.determined = determined;
- }
-
- public boolean isAjaxMode() {
- return ajaxMode;
- }
-
- public void setAjaxMode(boolean ajaxMode) {
- this.ajaxMode = ajaxMode;
- }
-
- public String getModeString() {
- return ajaxMode ? "ajax" : "client";
- }
-
-}
\ No newline at end of file
Copied: trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/Bean.java (from rev 5969, trunk/sandbox/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java)
===================================================================
--- trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/Bean.java (rev 0)
+++ trunk/samples/progressBarDemo/src/main/java/org/richfaces/samples/Bean.java 2008-02-09 02:00:25 UTC (rev 5971)
@@ -0,0 +1,116 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.samples;
+
+
+import java.util.Date;
+
+/**
+ * @author $Autor$
+ *
+ */
+public class Bean {
+
+ private boolean enabled = false;
+ private boolean permanent = false;
+ private boolean determined = true;
+ private boolean ajaxMode;
+
+ private Integer value = 0;
+
+ public String action () {
+ System.out.println("Bean.action()");
+ return null;
+ }
+
+ public String start() {
+ this.enabled = true;
+ return null;
+ }
+
+ public String getDate() {
+ Date date = new Date();
+ return date.toLocaleString();
+ }
+
+ /**
+ * @return the value
+ */
+ public Integer getValue() {
+ //value = value.add(new BigDecimal(0.6));
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+
+ public Integer getIncValue() {
+ return value++;
+ }
+
+ /**
+ * @return the enabled
+ */
+ public boolean getEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public boolean isPermanent() {
+ return permanent;
+ }
+
+ public void setPermanent(boolean permanent) {
+ this.permanent = permanent;
+ }
+
+ public boolean isDetermined() {
+ return determined;
+ }
+
+ public void setDetermined(boolean determined) {
+ this.determined = determined;
+ }
+
+ public boolean isAjaxMode() {
+ return ajaxMode;
+ }
+
+ public void setAjaxMode(boolean ajaxMode) {
+ this.ajaxMode = ajaxMode;
+ }
+
+ public String getModeString() {
+ return ajaxMode ? "ajax" : "client";
+ }
+
+}
\ No newline at end of file
Modified: trunk/samples/progressBarDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox/samples/progressBarDemo/src/main/webapp/WEB-INF/faces-config.xml 2008-02-08 18:58:01 UTC (rev 5966)
+++ trunk/samples/progressBarDemo/src/main/webapp/WEB-INF/faces-config.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -4,7 +4,7 @@
<faces-config>
<managed-bean>
<managed-bean-name>bean</managed-bean-name>
- <managed-bean-class>org.richfaces.sandbox.samples.Bean</managed-bean-class>
+ <managed-bean-class>org.richfaces.samples.Bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
Deleted: trunk/samples/progressBarDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/progressBarDemo/src/main/webapp/pages/index.jsp 2008-02-08 18:58:01 UTC (rev 5966)
+++ trunk/samples/progressBarDemo/src/main/webapp/pages/index.jsp 2008-02-09 02:00:25 UTC (rev 5971)
@@ -1,95 +0,0 @@
-<%@ 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://labs.jboss.com/jbossrichfaces/ui/ui/progressBar" prefix="progressBar" %>
-<html>
- <head>
- <title></title>
- <style>
- body{font-size : 11px}
- .complete {
- background-color: green;
- color: white;
- }
- .remain {
- background-color: #FCBBCD;
- }
- .main {
- font-size: 12px;
- font-weight: bold;
- }
- </style>
- </head>
- <body>
- <f:view>
-
- <h:form>
- <h:selectOneRadio binding="#{skinBean.component}" />
- <h:commandLink action="#{skinBean.change}" value="set skin" />
- </h:form>
-
- <h:form>
- <h:panelGrid columns="3">
- <h:outputText value="Progress value: " />
- <h:inputText value="#{bean.value}" />
-
- <h:commandButton value="Set" />
- </h:panelGrid>
-
- </h:form>
-
- <h:form id="_form">
-
- <progressBar:progressBar value="#{bean.incValue}" enabled="#{bean.enabled}" id="progrs"
- interval="700"
- reRender="per1"
- reRenderAfterComplete="per2"
- mode="#{bean.modeString}"
- progressVar="percent"
- parameters="text:'crack'"
- style="width: 300px; height: 15px;"
- action="#{bean.action}">
- <f:facet name="initial">
- <h:outputText value="Process not started"></h:outputText>
- </f:facet>
- <f:facet name="complete">
- <h:outputText value="Process completed"></h:outputText>
- </f:facet>
- <h:outputText value="{value}%"></h:outputText>
- </progressBar:progressBar>
- <br clear="all"/>
- <table><tr>
- <td>ReRender:</td><td><h:outputText value="#{bean.date}" id="per1"></h:outputText></td></tr><tr>
- <td>ReRender after complete:</td><td><h:outputText value="#{bean.date}" id="per2"></h:outputText></td>
- </tr></table></h:form>
-
- <h:form>
- Enabled: <h:selectBooleanCheckbox value="#{bean.enabled}" id="flag">
- <a4j:support event="onclick" reRender="progrs"></a4j:support>
- </h:selectBooleanCheckbox>
-
- <f:verbatim><br /></f:verbatim>
-
-
- Ajax mode: <h:selectBooleanCheckbox value="#{bean.ajaxMode}" id="flag3">
- <a4j:support event="onclick" reRender="progrs"></a4j:support>
- </h:selectBooleanCheckbox>
- <f:verbatim><br /></f:verbatim>
- </h:form>
- <script>
- var pr = $('_form:progrs').component;
- </script>
- <input type="button" value="Get value" onclick="alert($('_form:progrs').component.getValue());" /><br/>
- <input type="text" value="" id="percent"/>
- <input type="button" value="Set value" onclick="$('_form:progrs').component.setValue(document.getElementById('percent').value);" />
- <br/>
- <input type="text" value="" id="label"/>
- <input type="button" value="Set label" onclick="$('_form:progrs').component.setLabel(document.getElementById('label').value);" />
- <br/>
- <input type="button" value="Disable" onclick="$('_form:progrs').component.disable();" />
- <br/>
- <input type="button" value="Enable" onclick="$('_form:progrs').component.enable(event);" />
-
- </f:view>
- </body>
-</html>
Copied: trunk/samples/progressBarDemo/src/main/webapp/pages/index.jsp (from rev 5969, trunk/sandbox/samples/progressBarDemo/src/main/webapp/pages/index.jsp)
===================================================================
--- trunk/samples/progressBarDemo/src/main/webapp/pages/index.jsp (rev 0)
+++ trunk/samples/progressBarDemo/src/main/webapp/pages/index.jsp 2008-02-09 02:00:25 UTC (rev 5971)
@@ -0,0 +1,105 @@
+<%@ 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://labs.jboss.com/jbossrichfaces/ui/progressBar" prefix="progressBar" %>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/componentControl" prefix="cctrl" %>
+<html>
+ <head>
+ <title></title>
+ <style>
+ body{font-size : 11px}
+ .complete {
+ background-color: green;
+ color: white;
+ }
+ .remain {
+ background-color: #FCBBCD;
+ }
+ .main {
+ font-size: 12px;
+ font-weight: bold;
+ }
+ </style>
+ </head>
+ <body>
+ <f:view>
+
+ <h:form>
+ <h:selectOneRadio binding="#{skinBean.component}" />
+ <h:commandLink action="#{skinBean.change}" value="set skin" />
+ </h:form>
+
+ <h:form>
+ <h:panelGrid columns="3">
+ <h:outputText value="Progress value: " />
+ <h:inputText value="#{bean.value}" />
+
+ <h:commandButton value="Set" />
+ </h:panelGrid>
+
+ </h:form>
+
+ <h:form id="_form">
+
+ <progressBar:progressBar value="#{bean.incValue}" enabled="#{bean.enabled}" id="progrs"
+ interval="700"
+ reRender="per1"
+ reRenderAfterComplete="per2"
+ mode="#{bean.modeString}"
+ progressVar="percent"
+ parameters="text:'crack'"
+ style="width: 300px; height: 14px;"
+ action="#{bean.action}">
+ <f:facet name="initial">
+ <h:outputText value="Process not started"></h:outputText>
+ </f:facet>
+ <f:facet name="complete">
+ <h:outputText value="Process completed"></h:outputText>
+ </f:facet>
+ <h:outputText value="{value}%"></h:outputText>
+ </progressBar:progressBar>
+ <br clear="all"/>
+ <table><tr>
+ <td>ReRender:</td><td><h:outputText value="#{bean.date}" id="per1"></h:outputText></td></tr><tr>
+ <td>ReRender after complete:</td><td><h:outputText value="#{bean.date}" id="per2"></h:outputText></td>
+ </tr></table></h:form>
+
+ <h:form>
+ Enabled: <h:selectBooleanCheckbox value="#{bean.enabled}" id="flag">
+ <a4j:support event="onclick" reRender="progrs"></a4j:support>
+ </h:selectBooleanCheckbox>
+
+ <f:verbatim><br /></f:verbatim>
+
+
+ Ajax mode: <h:selectBooleanCheckbox value="#{bean.ajaxMode}" id="flag3">
+ <a4j:support event="onclick" reRender="progrs"></a4j:support>
+ </h:selectBooleanCheckbox>
+ <f:verbatim><br /></f:verbatim>
+ </h:form>
+ <script>
+ var pr = $('_form:progrs').component;
+ </script>
+ <input type="button" value="Get value" onclick="alert($('_form:progrs').component.getValue());" /><br/>
+ <input type="text" value="" id="percent"/>
+ <input type="button" value="Set value" onclick="$('_form:progrs').component.setValue(document.getElementById('percent').value);" />
+ <input type="button" id="ctrlValueButton" value="Set value by componentControl" />
+ <cctrl:componentControl attachTo="ctrlValueButton" for="progrs" event="click" disableDefault="true" operation="setValue">
+ <a4j:actionparam name="value" value="$F('percent')" noEscape="true" />
+ </cctrl:componentControl>
+ <br/>
+
+ <input type="text" value="111" id="label"/>
+ <input type="button" value="Set label" onclick="$('_form:progrs').component.setLabel(document.getElementById('label').value);" />
+ <input type="button" id="ctrlLabelButton" value="Set label by componentControl" />
+ <cctrl:componentControl attachTo="ctrlLabelButton" for="progrs" event="click" disableDefault="true" operation="setLabel">
+ <a4j:actionparam name="label" value="$F('label')" noEscape="true" />
+ </cctrl:componentControl>
+ <br/>
+ <input type="button" value="Disable" onclick="$('_form:progrs').component.disable();" />
+ <br/>
+ <input type="button" value="Enable" onclick="$('_form:progrs').component.enable(event);" />
+ <br />
+ </f:view>
+ </body>
+</html>
Modified: trunk/samples/progressBarDemo/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/sandbox/samples/progressBarDemo/src/main/webapp/pages/index.xhtml 2008-02-08 18:58:01 UTC (rev 5966)
+++ trunk/samples/progressBarDemo/src/main/webapp/pages/index.xhtml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -5,7 +5,7 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
xmlns:c="http://java.sun.com/jsp/jstl/core"
- xmlns:progressBar="http://labs.jboss.com/jbossrichfaces/ui/ui/progressBar"
+ xmlns:progressBar="http://labs.jboss.com/jbossrichfaces/ui/progressBar"
>
<f:view>
Modified: trunk/sandbox/samples/pom.xml
===================================================================
--- trunk/sandbox/samples/pom.xml 2008-02-09 01:14:34 UTC (rev 5970)
+++ trunk/sandbox/samples/pom.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -18,7 +18,6 @@
<!--module>contextMenuDemo</module-->
<module>fileUploadPOC</module>
<module>fileUploadDemo</module>
- <module>progressBarDemo</module>
<module>sortingFilteringDemo</module>
</modules>
</project>
\ No newline at end of file
Modified: trunk/sandbox/ui/pom.xml
===================================================================
--- trunk/sandbox/ui/pom.xml 2008-02-09 01:14:34 UTC (rev 5970)
+++ trunk/sandbox/ui/pom.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -20,6 +20,5 @@
<!--module>rex-button</module-->
<module>sortableHeader</module>
<module>fileUpload</module>
- <module>progressBAR</module>
</modules>
</project>
\ No newline at end of file
Modified: trunk/ui/pom.xml
===================================================================
--- trunk/ui/pom.xml 2008-02-09 01:14:34 UTC (rev 5970)
+++ trunk/ui/pom.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -106,6 +106,7 @@
<module>columns</module>
<module>combobox</module>
<module>pickList</module>
+ <module>progressBAR</module>
</modules>
<dependencies>
<dependency>
Copied: trunk/ui/progressBAR (from rev 5966, trunk/sandbox/ui/progressBAR)
Modified: trunk/ui/progressBAR/pom.xml
===================================================================
--- trunk/sandbox/ui/progressBAR/pom.xml 2008-02-08 18:58:01 UTC (rev 5966)
+++ trunk/ui/progressBAR/pom.xml 2008-02-09 02:00:25 UTC (rev 5971)
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<parent>
<artifactId>ui</artifactId>
- <groupId>org.richfaces.sandbox</groupId>
+ <groupId>org.richfaces</groupId>
<version>3.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.sandbox.ui</groupId>
+ <groupId>org.richfaces.ui</groupId>
<artifactId>progressBar</artifactId>
<name>progressBar</name>
<version>3.2.0-SNAPSHOT</version>
@@ -25,7 +25,7 @@
</executions>
<configuration>
<library>
- <prefix>org.richfaces.sandbox.ui</prefix>
+ <prefix>org.richfaces.ui</prefix>
<taglib>
<shortName>progressBar</shortName>
</taglib>
@@ -36,12 +36,6 @@
</build>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl</artifactId>
<version>3.2.0-SNAPSHOT</version>
@@ -52,4 +46,4 @@
<version>3.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Deleted: trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js 2008-02-08 18:58:01 UTC (rev 5966)
+++ trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js 2008-02-09 02:00:25 UTC (rev 5971)
@@ -1,215 +0,0 @@
-ProgressBar = {};
-ProgressBar = Class.create();
-Object.extend(ProgressBar.prototype, {
- initialize: function(id, containerId, formId, mode, minValue, maxValue, context, markup, options, progressVar, state, value) {
- this.id = id;
-
- this.containerId = containerId;
- this.formId = formId;
- this.mode = mode;
- this.state = state;
- this.minValue = minValue;
- this.maxValue = maxValue;
- this.value = value;
-
- this.context = context;
- this.markup = markup;
- this.options = options || {};
-
- this.options.onbeforedomupdate = function(request, event, data) {
- this.onComplete(data);
- }.bind(this);
-
- this.progressVar = progressVar;
- $(this.id).component = this;
- },
-
- getValue: function () {
- return this.value;
- },
- onComplete: function (data) {
- if (!$(this.id)) { return; }
- if (data) {
- this.value = data['percent'];
- if (this.state == "progressState") {
- this.updateComponent(data);
- this.renderLabel(data['markup'], data['context']);
- if (this.value >= this.getMaxValue()) {
- this.forceState("complete",null);
- return;
- }
- } else if (this.state == "initialState" && this.value >= this.getMinValue()) {
- this.state = "progressState";
- this.forceState("progressState", function () { this.poll() }.bind(this));
- return;
- }
- this.poll();
- }
-
- },
- poll: function () {
- A4J.AJAX.Poll(this.containerId, this.formId, this.options);
- },
- interpolate: function (placeholders) {
- for(var k in this.context) {
- var v = this.context[k];
- var regexp = new RegExp("\\{" + k + "\\}", "g");
- placeholders = placeholders.replace(regexp, v);
- }
- return placeholders;
- },
- updateComponent: function (data) {
- this.updateStyle(data['style']);
- this.setValue(data['percent']);
- if (!data['enabled']) { this.disable(); }
- this.updateClassName($(this.id + ":complete"), data['completeClass']);
- this.updateClassName($(this.id + ":remain"), data['remainClass']);
- this.updateClassName($(this.id), data['styleClass']);
-
- if (this.options.pollinterval != data['interval']) {
- this.options.pollinterval = data['interval'];
- }
- },
- updateStyle: function (style) {
- if (!style) { return; }
- var d = $(this.id);
- if (d.style)
- if (d.style.cssText != style) {
- d.style.cssText = style;
- d = $(this.id + ":remain");
- if (d) d.style.cssText = style;
- d = $(this.id + ":complete");
- if (d) d.style.cssText = style;
- d = $(this.id + ":upload");
- if (d) d.style.cssText = style;
- }
- },
- updateClassName: function (o, newName) {
- if (!newName) return;
- if (o && o.className) {
- if (o.className.indexOf(newName) < 0){
- o.className = o.className + " " + newName;
- }
- }
- },
- getContext: function () {
- var context = this.context;
- if (!context) { context = {}; }
- context['minValue'] = this.minValue;
- context['maxValue'] = this.maxValue;
- context['value'] = (this.value == 0 ? "0" : this.value);
- if (this.progressVar) {
- context[this.progressVar] = context['value'];
- }
- return context;
- },
- renderLabel: function (markup, context) {
- if (!markup || this.state != "progressState") {
- return;
- }
- if (!context) {
- context = this.getContext();
- }
- var html = markup.invoke('getContent', context).join('');
- $(this.id + ":remain").innerHTML = $(this.id + ":complete").innerHTML = html;
- },
- interpolate: function (placeholders, context) {
- for(var k in context) {
- var v = context[k];
- var regexp = new RegExp("\\{" + k + "\\}", "g");
- placeholders = placeholders.replace(regexp, v);
- }
- return placeholders;
- },
- setLabel: function (str) {
- if (this.state != "progressState") { return; }
- var d = $(this.id + ":remain");
- if (!d) { return; }
- var lbl = this.interpolate(str, this.getContext());
- if (lbl)
- d.innerHTML = $(this.id + ":complete").innerHTML = lbl;
- this.markup = null;
- },
- getMode: function () {
- return this.mode;
- },
- getMaxValue: function () {
- return this.maxValue;
- },
- getMinValue: function () {
- return this.minValue;
- },
- isAjaxMode: function () {
- return (this.getMode() == "ajax");
- },
- setValue: function (val) {
- this.value = val;
- var p = val;
- val = "" + val;
- if (val != null) {
- if (val.indexOf("%") < 0)
- val = val + "%";
- }
-
- if (!this.isAjaxMode()) {
- if ( parseFloat(p) <= parseFloat(this.getMinValue())) {
- this.switchState("initialState");
- }else if ( parseFloat(p) >= parseFloat(this.getMaxValue())) {
- this.switchState("completeState");
- }else {
- this.switchState("progressState");
- }
- }
- if (!this.isAjaxMode() && this.state != "progressState") return;
-
- if (this.markup) {
- this.renderLabel(this.markup, this.getContext());
- } else {
- //this.setLabel("{value}%");
- }
-
- var d = $(this.id + ":upload");
- if (d != null) d.style.width = val;
-
- },
- enable: function (ev) {
- if (!this.isAjaxMode()) {
- this.switchState("progressState");
- this.setValue(0);
- }else {
- this.disable();
- this.poll();
- }
- },
- disable: function () {
- A4J.AJAX.StopPoll(this.id);
- },
- finish: function () {
- //this.switchMode("completed");
- },
- hideAll: function () {
- Element.hide($(this.id + ":progressState"));
- Element.hide($(this.id + ":completeState"));
- Element.hide($(this.id + ":initialState"));
- },
- switchState: function (state) {
- this.state = state;
- this.hideAll();
- Element.show($(this.id + ":" + state));
- },
- renderState: function (state) {
- this.state = state;
- Element.show($(this.id + ":" + state));
- },
- forceState: function (state, oncomplete) {
- var options = {};
- options['parameters'] = {};
- options['parameters'][this.id] = this.id;
- options['parameters']['forcePercent'] = state;
- options['actionUrl'] = this.options.actionUrl;
- if (oncomplete) {
- options['oncomplete'] = oncomplete;
- }
- A4J.AJAX.SubmitRequest(this.containerId, this.formId, null, options);
- }
- });
Copied: trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js (from rev 5970, trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js)
===================================================================
--- trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js (rev 0)
+++ trunk/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js 2008-02-09 02:00:25 UTC (rev 5971)
@@ -0,0 +1,234 @@
+ProgressBar = {};
+ProgressBar = Class.create();
+Object.extend(ProgressBar.prototype, {
+ initialize: function(id, containerId, formId, mode, minValue, maxValue, context, markup, options, progressVar, state, value) {
+ this.id = id;
+
+ this.containerId = containerId;
+ this.formId = formId;
+ this.mode = mode;
+ this.state = state;
+ this.minValue = minValue;
+ this.maxValue = maxValue;
+ this.value = value;
+
+ this.context = context;
+ this.markup = markup;
+ this.options = options || {};
+
+ this.options.onbeforedomupdate = function(request, event, data) {
+ this.onComplete(data);
+ }.bind(this);
+
+ this.progressVar = progressVar;
+ $(this.id).component = this;
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+ onComplete: function (data) {
+ if (!$(this.id)) { return; }
+ if (data) {
+ this.value = data['percent'];
+ if (this.state == "progressState") {
+ this.updateComponent(data);
+ this.renderLabel(data['markup'], data['context']);
+ if (this.value >= this.getMaxValue()) {
+ this.forceState("complete",null);
+ return;
+ }
+ } else if (this.state == "initialState" && this.value >= this.getMinValue()) {
+ this.state = "progressState";
+ this.forceState("progressState", function () { this.poll() }.bind(this));
+ return;
+ }
+ this.poll();
+ }
+
+ },
+ poll: function () {
+ A4J.AJAX.Poll(this.containerId, this.formId, this.options);
+ },
+ interpolate: function (placeholders) {
+ for(var k in this.context) {
+ var v = this.context[k];
+ var regexp = new RegExp("\\{" + k + "\\}", "g");
+ placeholders = placeholders.replace(regexp, v);
+ }
+ return placeholders;
+ },
+ updateComponent: function (data) {
+ this.updateStyle(data['style']);
+ this.setValue(data['percent']);
+ if (!data['enabled']) { this.disable(); }
+ this.updateClassName($(this.id + ":complete"), data['completeClass']);
+ this.updateClassName($(this.id + ":remain"), data['remainClass']);
+ this.updateClassName($(this.id), data['styleClass']);
+
+ if (this.options.pollinterval != data['interval']) {
+ this.options.pollinterval = data['interval'];
+ }
+ },
+ updateStyle: function (style) {
+ if (!style) { return; }
+ var d = $(this.id);
+ if (d.style)
+ if (d.style.cssText != style) {
+ d.style.cssText = style;
+ d = $(this.id + ":remain");
+ if (d) d.style.cssText = style;
+ d = $(this.id + ":complete");
+ if (d) d.style.cssText = style;
+ d = $(this.id + ":upload");
+ if (d) d.style.cssText = style;
+ }
+ },
+ updateClassName: function (o, newName) {
+ if (!newName) return;
+ if (o && o.className) {
+ if (o.className.indexOf(newName) < 0){
+ o.className = o.className + " " + newName;
+ }
+ }
+ },
+ getContext: function () {
+ var context = this.context;
+ if (!context) { context = {}; }
+ context['minValue'] = this.minValue;
+ context['maxValue'] = this.maxValue;
+ context['value'] = (this.value == 0 ? "0" : this.value);
+ if (this.progressVar) {
+ context[this.progressVar] = context['value'];
+ }
+ return context;
+ },
+ renderLabel: function (markup, context) {
+ if (!markup || this.state != "progressState") {
+ return;
+ }
+ if (!context) {
+ context = this.getContext();
+ }
+ var html = markup.invoke('getContent', context).join('');
+ $(this.id + ":remain").innerHTML = $(this.id + ":complete").innerHTML = html;
+ },
+ interpolate: function (placeholders, context) {
+ for(var k in context) {
+ var v = context[k];
+ var regexp = new RegExp("\\{" + k + "\\}", "g");
+ placeholders = placeholders.replace(regexp, v);
+ }
+ return placeholders;
+ },
+ setLabel: function (arg, params) {
+ var str;
+
+ if (params && params.label) {
+ //componentControl
+ str = params.label;
+ } else {
+ str = arg;
+ }
+
+ if (this.state != "progressState") { return; }
+ var d = $(this.id + ":remain");
+ if (!d) { return; }
+ var lbl = this.interpolate(str, this.getContext());
+ if (lbl)
+ d.innerHTML = $(this.id + ":complete").innerHTML = lbl;
+ this.markup = null;
+ },
+ getMode: function () {
+ return this.mode;
+ },
+ getMaxValue: function () {
+ return this.maxValue;
+ },
+ getMinValue: function () {
+ return this.minValue;
+ },
+
+ isAjaxMode: function () {
+ return (this.getMode() == "ajax");
+ },
+ setValue: function (arg, params) {
+ var val;
+
+ if (params && params.value) {
+ //componentControl
+ val = params.value;
+ } else {
+ val = arg;
+ }
+
+ this.value = val;
+ var p = val;
+ val = "" + val;
+ if (val != null) {
+ if (val.indexOf("%") < 0)
+ val = val + "%";
+ }
+
+ if (!this.isAjaxMode()) {
+ if ( parseFloat(p) <= parseFloat(this.getMinValue())) {
+ this.switchState("initialState");
+ }else if ( parseFloat(p) >= parseFloat(this.getMaxValue())) {
+ this.switchState("completeState");
+ }else {
+ this.switchState("progressState");
+ }
+ }
+ if (!this.isAjaxMode() && this.state != "progressState") return;
+
+ if (this.markup) {
+ this.renderLabel(this.markup, this.getContext());
+ } else {
+ //this.setLabel("{value}%");
+ }
+
+ var d = $(this.id + ":upload");
+ if (d != null) d.style.width = val;
+
+ },
+ enable: function (ev) {
+ if (!this.isAjaxMode()) {
+ this.switchState("progressState");
+ this.setValue(0);
+ }else {
+ this.disable();
+ this.poll();
+ }
+ },
+ disable: function () {
+ A4J.AJAX.StopPoll(this.id);
+ },
+ finish: function () {
+ //this.switchMode("completed");
+ },
+ hideAll: function () {
+ Element.hide($(this.id + ":progressState"));
+ Element.hide($(this.id + ":completeState"));
+ Element.hide($(this.id + ":initialState"));
+ },
+ switchState: function (state) {
+ this.state = state;
+ this.hideAll();
+ Element.show($(this.id + ":" + state));
+ },
+ renderState: function (state) {
+ this.state = state;
+ Element.show($(this.id + ":" + state));
+ },
+ forceState: function (state, oncomplete) {
+ var options = {};
+ options['parameters'] = {};
+ options['parameters'][this.id] = this.id;
+ options['parameters']['forcePercent'] = state;
+ options['actionUrl'] = this.options.actionUrl;
+ if (oncomplete) {
+ options['oncomplete'] = oncomplete;
+ }
+ A4J.AJAX.SubmitRequest(this.containerId, this.formId, null, options);
+ }
+ });
18 years, 2 months
JBoss Rich Faces SVN: r5970 - trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 20:14:34 -0500 (Fri, 08 Feb 2008)
New Revision: 5970
Modified:
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
Log:
ComponentControl & ProgressBar integration
Modified: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js 2008-02-09 01:14:31 UTC (rev 5969)
+++ trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js 2008-02-09 01:14:34 UTC (rev 5970)
@@ -121,7 +121,16 @@
}
return placeholders;
},
- setLabel: function (str) {
+ setLabel: function (arg, params) {
+ var str;
+
+ if (params && params.label) {
+ //componentControl
+ str = params.label;
+ } else {
+ str = arg;
+ }
+
if (this.state != "progressState") { return; }
var d = $(this.id + ":remain");
if (!d) { return; }
@@ -139,10 +148,20 @@
getMinValue: function () {
return this.minValue;
},
+
isAjaxMode: function () {
return (this.getMode() == "ajax");
},
- setValue: function (val) {
+ setValue: function (arg, params) {
+ var val;
+
+ if (params && params.value) {
+ //componentControl
+ val = params.value;
+ } else {
+ val = arg;
+ }
+
this.value = val;
var p = val;
val = "" + val;
18 years, 2 months
JBoss Rich Faces SVN: r5969 - in trunk/sandbox/samples/progressBarDemo: src/main/java/org/richfaces/sandbox/samples and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 20:14:31 -0500 (Fri, 08 Feb 2008)
New Revision: 5969
Modified:
trunk/sandbox/samples/progressBarDemo/pom.xml
trunk/sandbox/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java
trunk/sandbox/samples/progressBarDemo/src/main/webapp/pages/index.jsp
Log:
ComponentControl & ProgressBar integration
Modified: trunk/sandbox/samples/progressBarDemo/pom.xml
===================================================================
--- trunk/sandbox/samples/progressBarDemo/pom.xml 2008-02-09 01:03:54 UTC (rev 5968)
+++ trunk/sandbox/samples/progressBarDemo/pom.xml 2008-02-09 01:14:31 UTC (rev 5969)
@@ -30,6 +30,12 @@
<version>3.2.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>componentControl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.richfaces.samples</groupId>
<artifactId>skins</artifactId>
Modified: trunk/sandbox/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java
===================================================================
--- trunk/sandbox/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java 2008-02-09 01:03:54 UTC (rev 5968)
+++ trunk/sandbox/samples/progressBarDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java 2008-02-09 01:14:31 UTC (rev 5969)
@@ -36,9 +36,10 @@
private boolean ajaxMode;
private Integer value = 0;
-
- public String action () {
- return null;
+
+ public String action () {
+ System.out.println("Bean.action()");
+ return null;
}
public String start() {
Modified: trunk/sandbox/samples/progressBarDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/progressBarDemo/src/main/webapp/pages/index.jsp 2008-02-09 01:03:54 UTC (rev 5968)
+++ trunk/sandbox/samples/progressBarDemo/src/main/webapp/pages/index.jsp 2008-02-09 01:14:31 UTC (rev 5969)
@@ -2,6 +2,7 @@
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/ui/progressBar" prefix="progressBar" %>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/componentControl" prefix="cctrl" %>
<html>
<head>
<title></title>
@@ -47,7 +48,7 @@
mode="#{bean.modeString}"
progressVar="percent"
parameters="text:'crack'"
- style="width: 300px; height: 15px;"
+ style="width: 300px; height: 14px;"
action="#{bean.action}">
<f:facet name="initial">
<h:outputText value="Process not started"></h:outputText>
@@ -82,14 +83,23 @@
<input type="button" value="Get value" onclick="alert($('_form:progrs').component.getValue());" /><br/>
<input type="text" value="" id="percent"/>
<input type="button" value="Set value" onclick="$('_form:progrs').component.setValue(document.getElementById('percent').value);" />
+ <input type="button" id="ctrlValueButton" value="Set value by componentControl" />
+ <cctrl:componentControl attachTo="ctrlValueButton" for="progrs" event="click" disableDefault="true" operation="setValue">
+ <a4j:actionparam name="value" value="$F('percent')" noEscape="true" />
+ </cctrl:componentControl>
<br/>
- <input type="text" value="" id="label"/>
+
+ <input type="text" value="111" id="label"/>
<input type="button" value="Set label" onclick="$('_form:progrs').component.setLabel(document.getElementById('label').value);" />
+ <input type="button" id="ctrlLabelButton" value="Set label by componentControl" />
+ <cctrl:componentControl attachTo="ctrlLabelButton" for="progrs" event="click" disableDefault="true" operation="setLabel">
+ <a4j:actionparam name="label" value="$F('label')" noEscape="true" />
+ </cctrl:componentControl>
<br/>
<input type="button" value="Disable" onclick="$('_form:progrs').component.disable();" />
<br/>
<input type="button" value="Enable" onclick="$('_form:progrs').component.enable(event);" />
-
+ <br />
</f:view>
</body>
</html>
18 years, 2 months
JBoss Rich Faces SVN: r5968 - in trunk/ui/componentControl/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-02-08 20:03:54 -0500 (Fri, 08 Feb 2008)
New Revision: 5968
Modified:
trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js
trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2222
Modified: trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js
===================================================================
--- trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js 2008-02-08 22:20:12 UTC (rev 5967)
+++ trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js 2008-02-09 01:03:54 UTC (rev 5968)
@@ -41,7 +41,7 @@
Richfaces.componentControl.performOperation = function( cevent, forAttr, operation, params, disableDefault) {
Richfaces.componentControl.eachComponent(forAttr, function(component) {
- component[operation](cevent, params);
+ component[operation](cevent, params());
});
if (disableDefault) {
Event.stop(cevent);
Modified: trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx
===================================================================
--- trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx 2008-02-08 22:20:12 UTC (rev 5967)
+++ trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx 2008-02-09 01:03:54 UTC (rev 5968)
@@ -41,7 +41,7 @@
//<![CDATA[
function #{name}(cevent) {
Richfaces.componentControl.performOperation(
- cevent, '#{forAttr}', '#{operation}', {#{params}}, #{component.disableDefault} );
+ cevent, '#{forAttr}', '#{operation}', function() { return {#{params}}; }, #{component.disableDefault} );
}
//]]>
</script>
@@ -54,7 +54,7 @@
{
Richfaces.componentControl.attachEvent(
- '#{attachTo}', '#{event}', '#{forAttr}', '#{operation}', {#{params}}, #{component.disableDefault} );
+ '#{attachTo}', '#{event}', '#{forAttr}', '#{operation}', function() { return {#{params}}; }, #{component.disableDefault} );
}
//]]>
@@ -68,7 +68,7 @@
//<![CDATA[
jQuery(document).ready(function() {
Richfaces.componentControl.attachEvent(
- '#{attachTo}', '#{event}', '#{forAttr}', '#{operation}', {#{params}}, #{component.disableDefault} );
+ '#{attachTo}', '#{event}', '#{forAttr}', '#{operation}', function() { return {#{params}}; }, #{component.disableDefault} );
});
//]]>
18 years, 2 months
JBoss Rich Faces SVN: r5967 - in branches/3.1.x: framework/impl/src/main/java/org/ajax4jsf/resource and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-02-08 17:20:12 -0500 (Fri, 08 Feb 2008)
New Revision: 5967
Added:
branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/CompressedScriptRenderer.java
branches/3.1.x/ui/assembly/src/main/config/
Modified:
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Library.java
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Taglib.java
branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java
branches/3.1.x/framework/impl/src/main/resources/META-INF/resources-config.xml
branches/3.1.x/samples/tomahawkCompability/pom.xml
Log:
Merge fix for a http://jira.jboss.com/jira/browse/RF-2219 from trunk
Modified: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java 2008-02-08 18:58:01 UTC (rev 5966)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java 2008-02-08 22:20:12 UTC (rev 5967)
@@ -40,6 +40,7 @@
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.codehaus.plexus.velocity.DefaultVelocityComponent;
import org.codehaus.plexus.velocity.VelocityComponent;
/**
@@ -156,9 +157,11 @@
library.setPrefix(project.getGroupId());
}
+ getLog().debug("Default prefix for a generated packages: "+library.getPrefix());
if (null == library.getDescription()) {
library.setDescription(project.getDescription());
}
+ getLog().debug("Library description: "+library.getDescription());
if( null == library.getJsfVersion()){
String version = Library.JSF11;
// Check version-specific methods in UIComponent class
@@ -176,6 +179,10 @@
}
library.setJsfVersion(version);
}
+
+ //velocity = new DefaultVelocityComponent();
+
+ getLog().debug("Generate files for a JSF "+library.getJsfVersion());
Renderkit[] renderkits = library.getRenderkits();
if (null != renderkits) {
for (int i = 0; i < renderkits.length; i++) {
@@ -233,6 +240,8 @@
if(null == taglib.getTaglib()){
taglib.setTaglib(taglib.getShortName());
}
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
for (int i = 0; i < library.getTaglibs().length; i++) {
Taglib t = library.getTaglibs()[i];
@@ -259,16 +268,16 @@
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
try {
- List compileClasspathElements = project
+ List<?> compileClasspathElements = project
.getCompileClasspathElements();
String outputDirectory = project.getBuild().getOutputDirectory();
URL[] urls = new URL[compileClasspathElements.size() + 1];
int i = 0;
- urls[i++] = new File(outputDirectory).toURL();
- for (Iterator iter = compileClasspathElements.iterator(); iter
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+ for (Iterator<?> iter = compileClasspathElements.iterator(); iter
.hasNext();) {
String element = (String) iter.next();
- urls[i++] = new File(element).toURL();
+ urls[i++] = new File(element).toURI().toURL();
}
if (useCCL) {
@@ -306,7 +315,9 @@
if(null == taglib.getTaglib()){
taglib.setTaglib(taglib.getShortName());
}
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
}
-}
\ No newline at end of file
+}
Modified: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2008-02-08 18:58:01 UTC (rev 5966)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2008-02-08 22:20:12 UTC (rev 5967)
@@ -149,6 +149,13 @@
private MavenProject parentProject;
/**
+ * The list of resources we want to transfer.
+ *
+ * @parameter default-value="src/main/config"
+ */
+ private File config;
+
+ /**
* The directory for compiled classes.
*
* @parameter expression="${project.build.directory}"
@@ -504,47 +511,25 @@
* @throws MojoExecutionException
*/
private void mergeFacesConfig(List models) throws MojoExecutionException {
- StringBuffer config = new StringBuffer();
+ StringBuffer facesConfig = new StringBuffer();
for (int i = 0; i < library.getRenderkits().length; i++) {
Renderkit kit = library.getRenderkits()[i];
kit.setContent(new StringBuffer());
}
+ // Process all faces-config.xml from modules
for (Iterator iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
File moduleFacesConfig = new File(modulesDirectory, model
.getArtifactId()
+ "/META-INF/faces-config.xml");
- if (moduleFacesConfig.exists()) {
- getLog().info(
- "Process faces-config.xml for module "
- + model.getArtifactId());
- XMLBody configBody = new XMLBody();
- try {
- configBody.loadXML(new FileInputStream(moduleFacesConfig));
- config
- .append(configBody
- .getContent("/faces-config/*[name()!=\'render-kit\']"));
- for (int i = 0; i < library.getRenderkits().length; i++) {
- Renderkit kit = library.getRenderkits()[i];
- kit
- .getContent()
- .append(
- configBody
- .getContent("/faces-config/render-kit[child::render-kit-id='"
- + kit.getName()
- + "']/renderer"));
- }
- } catch (FileNotFoundException e) {
- throw new MojoExecutionException(
- "Could't read faces-config file", e);
- } catch (ParsingException e) {
- throw new MojoExecutionException(
- "Error parsing faces-config file", e);
- }
- }
+ processFacesConfigFile(facesConfig, moduleFacesConfig);
}
+ // Process faces-config from project resources
+ if (null !=config) {
+ processFacesConfigFile(facesConfig, new File(config, "META-INF/faces-config.xml"));
+ }
VelocityContext context = new VelocityContext();
- context.put("content", config.toString());
+ context.put("content", facesConfig.toString());
context.put("library", library);
context.put("renderkits", Arrays.asList(library.getRenderkits()));
try {
@@ -557,6 +542,42 @@
}
/**
+ * @param config
+ * @param moduleFacesConfig
+ * @throws MojoExecutionException
+ */
+ private void processFacesConfigFile(StringBuffer config,
+ File moduleFacesConfig) throws MojoExecutionException {
+ if (moduleFacesConfig.exists()) {
+ getLog().info(
+ "Process "+moduleFacesConfig.getName());
+ XMLBody configBody = new XMLBody();
+ try {
+ configBody.loadXML(new FileInputStream(moduleFacesConfig));
+ config
+ .append(configBody
+ .getContent("/faces-config/*[name()!=\'render-kit\']"));
+ for (int i = 0; i < library.getRenderkits().length; i++) {
+ Renderkit kit = library.getRenderkits()[i];
+ kit
+ .getContent()
+ .append(
+ configBody
+ .getContent("/faces-config/render-kit[child::render-kit-id='"
+ + kit.getName()
+ + "']/renderer"));
+ }
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException(
+ "Could't read faces-config file", e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing faces-config file", e);
+ }
+ }
+ }
+
+ /**
* Merge XML files from extracted models to one in build directory.
*
* @param models
@@ -586,42 +607,13 @@
for (Iterator iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
File moduleDir = new File(modulesDirectory, model.getArtifactId());
- DirectoryScanner ds = new DirectoryScanner();
- ds.setFollowSymlinks(true);
- ds.setBasedir(moduleDir);
- ds.setIncludes(split);
- ds.addDefaultExcludes();
- ds.scan();
- String[] files = ds.getIncludedFiles();
- for (int i = 0; i < files.length; i++) {
- File moduleFacesConfig = new File(moduleDir, files[i]);
- getLog().info(
- "Process " + files[i] + " for module "
- + model.getArtifactId());
- XMLBody configBody = new XMLBody();
- try {
- configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
- xmls.add(configBody);
- if (commonXpath != null) {
- if (keyXPath == null) {
- content.append(configBody.getContent(commonXpath));
- } else {
- content.append(configBody.getContentUnique(
- commonXpath, keyXPath, keySet));
- }
- } else {
- content.append(configBody.getContent());
- }
- } catch (FileNotFoundException e) {
- throw new MojoExecutionException("Could't read file "
- + moduleFacesConfig.getPath(), e);
- } catch (ParsingException e) {
- throw new MojoExecutionException(
- "Error parsing config file "
- + moduleFacesConfig.getPath(), e);
- }
- }
+ mergeXMLdir(moduleDir, commonXpath, keyXPath, namespaceAware,
+ keySet, content, xmls, split);
}
+ if(null!=config){
+ mergeXMLdir(config, commonXpath, keyXPath, namespaceAware,
+ keySet, content, xmls, split);
+ }
if (xmls.size() > 0) {
context.put("content", content.toString());
context.put("library", library);
@@ -637,6 +629,58 @@
}
}
+ /**
+ * @param moduleDir
+ * @param commonXpath
+ * @param keyXPath
+ * @param namespaceAware
+ * @param keySet
+ * @param content
+ * @param xmls
+ * @param split
+ * @throws IllegalStateException
+ * @throws MojoExecutionException
+ */
+ private void mergeXMLdir(File moduleDir, String commonXpath,
+ String keyXPath, boolean namespaceAware, Set<String> keySet,
+ StringBuffer content, List<XMLBody> xmls, String[] split)
+ throws IllegalStateException, MojoExecutionException {
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(moduleDir);
+ ds.setIncludes(split);
+ ds.addDefaultExcludes();
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (int i = 0; i < files.length; i++) {
+ File moduleFacesConfig = new File(moduleDir, files[i]);
+ getLog().info(
+ "Process " + files[i] );
+ XMLBody configBody = new XMLBody();
+ try {
+ configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
+ xmls.add(configBody);
+ if (commonXpath != null) {
+ if (keyXPath == null) {
+ content.append(configBody.getContent(commonXpath));
+ } else {
+ content.append(configBody.getContentUnique(
+ commonXpath, keyXPath, keySet));
+ }
+ } else {
+ content.append(configBody.getContent());
+ }
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Could't read file "
+ + moduleFacesConfig.getPath(), e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing config file "
+ + moduleFacesConfig.getPath(), e);
+ }
+ }
+ }
+
private void unpackArtifact(Artifact artifact, File moduleDir,
boolean isResource) throws MojoExecutionException {
try {
Modified: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Library.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Library.java 2008-02-08 18:58:01 UTC (rev 5966)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Library.java 2008-02-08 22:20:12 UTC (rev 5967)
@@ -144,4 +144,8 @@
this.taglibs = taglibs;
}
+ @Override
+ public String toString() {
+ return "JSF library "+getPrefix()+", desc: "+getDescription()+(null!=getTaglibs()?", libs: "+getTaglibs():"");
+ }
}
Modified: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Taglib.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Taglib.java 2008-02-08 18:58:01 UTC (rev 5966)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Taglib.java 2008-02-08 22:20:12 UTC (rev 5967)
@@ -220,4 +220,8 @@
_excludeTags = excludeTags;
}
+ @Override
+ public String toString() {
+ return "Lib: "+getShortName()+", URL: "+getUri();
+ }
}
Copied: branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/CompressedScriptRenderer.java (from rev 5966, trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CompressedScriptRenderer.java)
===================================================================
--- branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/CompressedScriptRenderer.java (rev 0)
+++ branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/CompressedScriptRenderer.java 2008-02-08 22:20:12 UTC (rev 5967)
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.ajax4jsf.resource;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class CompressedScriptRenderer extends OneTimeRenderer {
+
+ protected String getTag() {
+ // TODO Auto-generated method stub
+ return "script";
+ }
+
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return "src";
+ }
+
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return new String[][]{{"type",getContentType()}};
+ }
+
+ public String getContentType() {
+ // TODO - use configurable encoding ?
+ return "text/javascript";
+ }
+
+
+}
Modified: branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java
===================================================================
--- branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java 2008-02-08 18:58:01 UTC (rev 5966)
+++ branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java 2008-02-08 22:20:12 UTC (rev 5967)
@@ -37,45 +37,13 @@
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
*
*/
-public class ScriptRenderer extends OneTimeRenderer {
+public class ScriptRenderer extends CompressedScriptRenderer {
private static final String COMPRESS_SCRIPTS_PARAMETER = "org.ajax4jsf.COMPRESS_SCRIPT";
private static final Log _log = LogFactory.getLog(ScriptRenderer.class);
/* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- // TODO Auto-generated method stub
- return "script";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return "src";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return new String[][]{{"type",getContentType()}};
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO - use configurable encoding ?
- return "text/javascript";
- }
-
- /* (non-Javadoc)
* @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
*/
public int send(InternetResource base, ResourceContext context) throws IOException {
Modified: branches/3.1.x/framework/impl/src/main/resources/META-INF/resources-config.xml
===================================================================
--- branches/3.1.x/framework/impl/src/main/resources/META-INF/resources-config.xml 2008-02-08 18:58:01 UTC (rev 5966)
+++ branches/3.1.x/framework/impl/src/main/resources/META-INF/resources-config.xml 2008-02-08 22:20:12 UTC (rev 5967)
@@ -18,10 +18,15 @@
<renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
</resource>
<resource >
- <name>org/ajax4jsf/renderers/ajax/scripts/form.js</name>
- <path>/org/ajax4jsf/javascript/scripts/form.js</path>
- <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
+ <name>/org/ajax4jsf/framework.pack.js</name>
+ <path>org/ajax4jsf/framework.pack.js</path>
+ <renderer class="org.ajax4jsf.resource.CompressedScriptRenderer"/>
</resource>
+ <resource >
+ <name>org/ajax4jsf/renderers/ajax/scripts/form.js</name>
+ <path>/org/ajax4jsf/javascript/scripts/form.js</path>
+ <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
+ </resource>
<resource class="org.richfaces.renderkit.html.GradientA">
<name>org.richfaces.renderkit.html.GradientA</name>
</resource>
Modified: branches/3.1.x/samples/tomahawkCompability/pom.xml
===================================================================
--- branches/3.1.x/samples/tomahawkCompability/pom.xml 2008-02-08 18:58:01 UTC (rev 5966)
+++ branches/3.1.x/samples/tomahawkCompability/pom.xml 2008-02-08 22:20:12 UTC (rev 5967)
@@ -3,7 +3,7 @@
<parent>
<artifactId>samples</artifactId>
<groupId>org.richfaces</groupId>
- <version>1.1.1-SNAPSHOT</version>
+ <version>3.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.richfaces.samples</groupId>
Copied: branches/3.1.x/ui/assembly/src/main/config (from rev 5966, trunk/ui/assembly/src/main/config)
18 years, 2 months