[richfaces-svn-commits] JBoss Rich Faces SVN: r14653 - in branches/community/3.3.X/ui/progressBAR/src/main: resources/org/richfaces/renderkit/html/js and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Jun 17 13:02:20 EDT 2009


Author: konstantin.mishin
Date: 2009-06-17 13:02:20 -0400 (Wed, 17 Jun 2009)
New Revision: 14653

Modified:
   branches/community/3.3.X/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
   branches/community/3.3.X/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
Log:
RF-7386

Modified: branches/community/3.3.X/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
===================================================================
--- branches/community/3.3.X/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java	2009-06-17 15:04:53 UTC (rev 14652)
+++ branches/community/3.3.X/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java	2009-06-17 17:02:20 UTC (rev 14653)
@@ -30,6 +30,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.math.BigDecimal;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
@@ -53,6 +54,7 @@
 import org.ajax4jsf.renderkit.AjaxRendererUtils;
 import org.ajax4jsf.renderkit.ComponentVariables;
 import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.RendererUtils;
 import org.ajax4jsf.renderkit.RendererUtils.HTML;
 import org.ajax4jsf.resource.CountingOutputWriter;
 import org.apache.commons.logging.Log;
@@ -259,50 +261,29 @@
 		ComponentVariables variables = ComponentsVariableResolver.getVariables(
 				this, component);
 		StringBuffer script = new StringBuffer();
+        Map<String, Object> options = new HashMap<String, Object>();
+        RendererUtils utils = getUtils();
+
 		String clientId = component.getClientId(context);
 		String containerId = ((UIComponent) AjaxRendererUtils
 				.findAjaxContainer(context, component)).getClientId(context);
-		String mode = (String) component.getAttributes().get("mode");
-		UIComponent form = AjaxRendererUtils.getNestingForm(component);
-		String formId = "";
-		if (form != null) {
-			formId = form.getClientId(context);
-		} else if ("ajax".equals(mode)) {
-			// Ignore form absent. It can be rendered by forcing from any
-			// component
-			// throw new FaceletException("Progress bar component in ajax mode
-			// should be placed inside the form");
-		}
-		Number minValue = getNumber(component.getAttributes().get("minValue"));
-		Number maxValue = getNumber(component.getAttributes().get("maxValue"));
-		Number value = (Number) variables.getVariable("value");
+		
+        utils.addToScriptHash(options, "mode", component.getAttributes().get("mode"), "ajax"); 
+        utils.addToScriptHash(options, "minValue", component.getAttributes().get("minValue"), "0"); 
+        utils.addToScriptHash(options, "maxValue", component.getAttributes().get("maxValue"), "100"); 
+        utils.addToScriptHash(options, "context", getContext(component)); 
 		StringBuffer markup = getMarkup(context, component);
+        utils.addToScriptHash(options, "markup", markup != null ? new JSLiteral(markup.toString()) : null); 
+        utils.addToScriptHash(options, "options", buildAjaxOptions(clientId, progressBar, context)); 
+        utils.addToScriptHash(options, "progressVar", component.getAttributes().get("progressVar")); 
+        utils.addToScriptHash(options, "state", state, "initialState"); 
+        utils.addToScriptHash(options, "value", variables.getVariable("value")); 
 
 		script.append("new ProgressBar('").append(clientId).append("','") // id
-				.append(containerId).append("','") // containerId
-				.append(formId).append("','") // formId
-				.append(mode).append("',") // mode
-				.append(minValue).append(",") // min value
-				.append(maxValue).append(","); // max value
-		script.append(getContext(component)); // context
-		script.append(",");
-		script.append(markup != null ? new JSLiteral(markup.toString())
-				: JSReference.NULL); // markup
-		script.append(",");
-		script.append(ScriptUtils.toScript(buildAjaxOptions(clientId, // options
-				progressBar, context)));
-		String progressVar = (String) component.getAttributes().get(
-				"progressVar");
-		if (progressVar != null) {
-			script.append(",'");
-			script.append(progressVar); // progress var
-			script.append("','");
-		} else {
-			script.append(",null,'");
-		}
-		script.append(state);
-		script.append("',");
-		script.append(value.toString());
+				.append(containerId).append("'"); // containerId
+        if (!options.isEmpty()) {
+        	script.append(",").append(ScriptUtils.toScript(options));
+		}				
 		script.append(")\n;");
 		writer.write(script.toString());
 	}
@@ -602,8 +583,6 @@
 		if (parameters != null) {
 			buffer.append("{").append(parameters).append("}");
 			literal = new JSLiteral(buffer.toString());
-		} else {
-			literal = new JSLiteral("null");
 		}
 		return literal;
 	}

Modified: branches/community/3.3.X/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js
===================================================================
--- branches/community/3.3.X/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js	2009-06-17 15:04:53 UTC (rev 14652)
+++ branches/community/3.3.X/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js	2009-06-17 17:02:20 UTC (rev 14653)
@@ -1,26 +1,20 @@
 ProgressBar = {};
 ProgressBar = Class.create();
 Object.extend(ProgressBar.prototype, {
-    initialize: function(id, containerId, formId, mode, minValue, maxValue, context, markup, options, progressVar, state, value) {
+	
+	//default values of options
+	mode: "ajax",
+	minValue: 0,
+	maxValue: 100,
+	options : {},
+	state : "initialState",
+	
+    initialize: function(id, containerId, options) {
 		this.id = id;
-				
-		this.containerId = containerId;
-		if (formId != '') {
-			this.formId = formId;
-		}else {
-			var f = this.getForm();
-			this.formId = (f) ? f.id : null;
-		}
-		this.mode = mode;
-		this.state = state;
-		this.minValue = minValue;
-		this.maxValue = maxValue;
-		this.value = value;
+		Object.extend(this, options);		
+		var f = this.getForm();
+		this.formId = (f) ? f.id : null;
 		this.disabled = false;
-	
-		this.context = context;
-		this.markup = markup;
-		this.options = options || {};
 		
 		this.onbeforedomupdate = this.options.onbeforedomupdate;
 		
@@ -29,7 +23,6 @@
 			this.onComplete(data);
 		}.bind(this);
 		
-		this.progressVar = progressVar;
 		$(this.id).component = this;
     },
     




More information about the richfaces-svn-commits mailing list