[richfaces-svn-commits] JBoss Rich Faces SVN: r5847 - in trunk/sandbox/ui/progressBAR/src/main: resources/org/richfaces/renderkit/html/css and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Feb 5 21:09:45 EST 2008


Author: nbelaevski
Date: 2008-02-05 21:09:45 -0500 (Tue, 05 Feb 2008)
New Revision: 5847

Modified:
   trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
   trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
   trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
   trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx
Log:
Latest updates for progressBar & demo

Modified: trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java	2008-02-06 02:09:36 UTC (rev 5846)
+++ trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java	2008-02-06 02:09:45 UTC (rev 5847)
@@ -22,7 +22,6 @@
 import org.ajax4jsf.context.AjaxContext;
 import org.ajax4jsf.event.AjaxEvent;
 import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
 import org.ajax4jsf.javascript.JSLiteral;
 import org.ajax4jsf.javascript.JSReference;
 import org.ajax4jsf.javascript.ScriptUtils;
@@ -156,8 +155,8 @@
 	    JSFunction function = AjaxRendererUtils.buildAjaxFunction(
 		    component, context, AJAX_POLL_FUNCTION);
 
-	    function.addParameter(new JSReference("ProgressBar.Pollers['"
-		    + clientId + "']['options']"));
+	    function.addParameter(new JSReference("$('"
+		    + clientId + "').component.options"));
 	    function.appendScript(script);
 
 	    pollScript.append(script);
@@ -184,8 +183,8 @@
 	writer.startElement(HTML.SPAN_ELEM, component);
 	writer.startElement(HTML.SCRIPT_ELEM, component);
 	script.append(
-		"new ProgressBar('" + component.getClientId(context)
-			+ "').renderLabel(").append(
+		"$('" + component.getClientId(context)
+			+ "').component.renderLabel(").append(
 		getMarkup(context, component)).append(",null);\n");
 	writer.append(script.toString());
 	writer.endElement(HTML.SCRIPT_ELEM);
@@ -206,6 +205,7 @@
 	UIProgressBar progressBar = (UIProgressBar) component;
 
 	writer.startElement(HTML.SPAN_ELEM, component);
+	writer.writeAttribute(HTML.style_ATTRIBUTE, "display: none;", null);
 	writer.startElement(HTML.SCRIPT_ELEM, component);
 
 	StringBuffer script = new StringBuffer();
@@ -218,7 +218,7 @@
 	Integer minValue = (Integer) component.getAttributes().get("minValue");
 	Integer maxValue = (Integer) component.getAttributes().get("maxValue");
 
-	script.append("new ProgressBar().init('")
+	script.append("new ProgressBar('")
 		.append(clientId).append("','")    // id
 		.append(containerId).append("','") // containerId
 		.append(formId).append("','")      // formId
@@ -262,8 +262,8 @@
 	options.put("pollinterval", interval);
 	Map parameters = (Map) options.get("parameters");
 	parameters.put("percent", "percent");
-	options.put("onbeforedomupdate", getOnComplete(clientId, progressBar,
-		context));
+//	options.put("onbeforedomupdate", getOnComplete(clientId, progressBar,
+//		context));
 	return options;
     }
 
@@ -279,29 +279,6 @@
     }
 
     /**
-     * Creates oncomplete function
-     * 
-     * @param clientId
-     * @param component
-     * @param context
-     * @param writer
-     * @param options
-     * @return
-     */
-    public JSFunctionDefinition getOnComplete(String clientId,
-	    UIProgressBar component, FacesContext context) {
-	JSFunctionDefinition functionDefinition = new JSFunctionDefinition();
-	functionDefinition.addParameter("request");
-	functionDefinition.addParameter("event");
-	functionDefinition.addParameter("data");
-	StringBuffer body = new StringBuffer();
-	body.append("new ProgressBar('" + clientId + "').onComplete(data);");
-	functionDefinition.addToBody(body.toString());
-
-	return functionDefinition;
-    }
-
-    /**
      * Methods encodes start facet of progress bar component
      * 
      * @param context -
@@ -497,6 +474,7 @@
 	encodeInitialScript(context, component);
 	if (isAjax) {
 	    writer.startElement(HTML.SPAN_ELEM, component);
+		writer.writeAttribute(HTML.style_ATTRIBUTE, "display: none;", null);
 	    writer.startElement(HTML.SCRIPT_ELEM, component);
 	    writer.write(getStopPollScript(clientId).toString());
 	    writer.endElement(HTML.SCRIPT_ELEM);

Modified: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss	2008-02-06 02:09:36 UTC (rev 5846)
+++ trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss	2008-02-06 02:09:45 UTC (rev 5847)
@@ -8,8 +8,8 @@
 	<f:verbatim>
 		
 		
-.rich-progress-bar-uploaded{overflow : hidden; position : absolute; border : 0px solid ; height : 16px;}
-.rich-progress-bar{position : relative; margin-bottom : 2px; height : 16px; width : 200px}
+.rich-progress-bar-uploaded{overflow : hidden; position : absolute; border-style: solid; border-width: 1px 0px 1px 1px; height : 16px;}
+.rich-progress-bar{position : relative; margin-bottom : 2px; height : 16px; width : 200px; white-space: nowrap;}
 .rich-progress-bar-base{text-align : center; position : absolute; height : 16px; width : 200px; font-weight : bold;}
 .rich-progress-bar-remained{border : 1px solid; color : #000000;}
 .rich-progress-bar-completed{background-repeat : repeat-x; repeat-y;}

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-06 02:09:36 UTC (rev 5846)
+++ trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js	2008-02-06 02:09:45 UTC (rev 5847)
@@ -1,24 +1,26 @@
 ProgressBar = {};
 ProgressBar = Class.create();
-ProgressBar.Pollers = {}
 Object.extend(ProgressBar.prototype, {
-    initialize: function() {
-    	if (arguments.length > 0) {
-    		var id = arguments[0];
-    		this.id = id;
-    	}
+    initialize: function(id, containerId, formId, mode, minValue, maxValue, context, options, progressVar) {
+		this.id = id;
+		$(this.id).component = this;
+		
+		this.containerId = containerId;
+		this.formId = formId;
+		this.mode = mode;
+		this.minValue = minValue;
+		this.maxValue = maxValue;
+	
+		this.context = context;
+		this.options = options || {};
+		
+		this.options.onbeforedomupdate = function(request, event, data) {
+			this.onComplete(data);
+		}.bind(this);
+		
+		this.progressVar = progressVar;
     },
-    init: function (id, containerId, formId, mode, minValue, maxValue, context, options, progressVar) {
-    	ProgressBar.Pollers[id] = {};
-    	ProgressBar.Pollers[id]['containerId'] = containerId;
-    	ProgressBar.Pollers[id]['formId'] = formId;
-    	ProgressBar.Pollers[id]['mode'] = mode;
-    	ProgressBar.Pollers[id]['minValue'] = minValue;
-    	ProgressBar.Pollers[id]['maxValue'] = maxValue;
-    	ProgressBar.Pollers[id]['context'] = context;
-    	ProgressBar.Pollers[id]['options'] = options;
-    	ProgressBar.Pollers[id]['progressVar'] = progressVar;
-    },
+
 	getValue: function () {
 		var d = $(this.id + ":upload");
 		if (d != null) {
@@ -39,7 +41,7 @@
 		
 	},
 	poll: function () {
-			A4J.AJAX.Poll(ProgressBar.Pollers[this.id]['containerId'], ProgressBar.Pollers[this.id]['formId'], ProgressBar.Pollers[this.id]['options']);
+			A4J.AJAX.Poll(this.containerId, this.formId, this.options);
 	},
 	interpolate: function (placeholders) {
 		for(var k in this.context) {
@@ -57,8 +59,8 @@
 		this.updateClassName($(this.id + ":remain"), data['remainClass'], "rich-progress-bar-base");
 		this.updateClassName($(this.id), data['styleClass'], "rich-progress-bar-base");
 		
-		if (ProgressBar.Pollers[this.id]['options']['pollinterval'] != data['interval']) {
-			ProgressBar.Pollers[this.id]['options']['pollinterval'] = data['interval'];
+		if (this.options.pollinterval != data['interval']) {
+			this.options.pollinterval = data['interval'];
 		}
 	},
 	updateStyle: function (style) {
@@ -76,20 +78,20 @@
 		}
 	},
 	updateClassName: function (o, newName, defaultClass) {
-		if (o.className) {
+		if (o && o.className) {
 			if (o.className.indexOf(newName) < 0){
 				o.className = newName + " "+ defaultClass;
 			}
 		}
 	},
 	getContext: function () {
-		var context = ProgressBar.Pollers[this.id]['context'];
+		var context = this.context;
 		if (!context) { context = {}; }
-			context['minValue'] = ProgressBar.Pollers[this.id]['minValue'];
-			context['maxValue'] = ProgressBar.Pollers[this.id]['maxValue'];
+			context['minValue'] = this.minValue;
+			context['maxValue'] = this.maxValue;
 			context['value'] = (this.value ? this.value : this.getValue());
-			if (ProgressBar.Pollers[this.id]['progressVar']) {
-				context[ProgressBar.Pollers[this.id]['progressVar']] = context['value'];
+			if (this.progressVar) {
+				context[this.progressVar] = context['value'];
 			}
 		return context;
 	},
@@ -117,13 +119,13 @@
 			$(this.id + ":remain").innerHTML = $(this.id + ":complete").innerHTML = lbl;
 	},
 	getMode: function () {
-		return ProgressBar.Pollers[this.id]['mode'];
+		return this.mode;
 	},
 	getMaxValue: function () {
-		return ProgressBar.Pollers[this.id]['maxValue'];	
+		return this.maxValue;	
 	},
 	getMinValue: function () {
-		return ProgressBar.Pollers[this.id]['minValue'];
+		return this.minValue;
 	},
 	isAjaxMode: function () {
 		return (this.getMode() == "ajax");
@@ -153,7 +155,9 @@
 	},
 	enable: function (ev) {
 		if (!this.isAjaxMode()) {
-			this.forceState("progress",new Function ("new ProgressBar('"+this.id+"').setValue('0');"));
+			this.forceState("progress", function() { 
+				this.setValue(0); 
+			}.bind(this));
 		}else {
 			this.disable();
 			this.poll();			
@@ -170,10 +174,10 @@
 		options['parameters'] = {};
 		options['parameters'][this.id] = this.id;
 		options['parameters']['forceState'] = state;
-		options['actionUrl'] = ProgressBar.Pollers[this.id]['options']['actionUrl'];
+		options['actionUrl'] = this.options.actionUrl;
 		if (oncomplete) {
 			options['oncomplete'] = oncomplete;
 		}
-		A4J.AJAX.SubmitRequest(ProgressBar.Pollers[this.id]['containerId'],ProgressBar.Pollers[this.id]['formId'],null,options);
+		A4J.AJAX.SubmitRequest(this.containerId, this.formId, null, options);
 	}
 	});

Modified: trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx	2008-02-06 02:09:36 UTC (rev 5846)
+++ trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx	2008-02-06 02:09:45 UTC (rev 5847)
@@ -40,9 +40,9 @@
 <![CDATA[
 if (forcedState != null) {
     renderForcedState(forcedState,context,component);
-}else if (value.doubleValue() < minValue.doubleValue()) { 
+}else if (value.doubleValue() <= minValue.doubleValue()) { 
     encodeInitialState(context, component);
-} else if (value.doubleValue() > maxValue.doubleValue()) {
+} else if (value.doubleValue() >= maxValue.doubleValue()) {
     encodeCompletedState(context, component);
 } else  {
     encodeProgressState(context, component);




More information about the richfaces-svn-commits mailing list