[richfaces-svn-commits] JBoss Rich Faces SVN: r5258 - in trunk/sandbox/ui/progressBAR/src: main/java/org/richfaces/renderkit and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Jan 10 07:26:23 EST 2008


Author: andrei_exadel
Date: 2008-01-10 07:26:23 -0500 (Thu, 10 Jan 2008)
New Revision: 5258

Modified:
   trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml
   trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
   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
   trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java
Log:
attributes refactoring

Modified: trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml	2008-01-10 12:14:17 UTC (rev 5257)
+++ trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml	2008-01-10 12:26:23 UTC (rev 5258)
@@ -32,8 +32,9 @@
 			<name>mode</name>
 			<classname>java.lang.String</classname>
 			<description>Attributes defines AJAX or CLIENT modes for component</description>
+			<defaultvalue><![CDATA["ajax"]]></defaultvalue>
 		</property>
-		<property>
+		<property>	
 			<name>styleClass</name>
 			<classname>java.lang.String</classname>
 			<description>CSS class that defines style for progress bar</description>
@@ -50,13 +51,15 @@
 		</property>
 		<property>
 			<name>determined</name>
-			<classname>java.lang.String</classname>
+			<classname>boolean</classname>
 			<description>Attribute defines if component should render percent value</description>
+			<defaultvalue>true</defaultvalue>
 		</property>
 		<property>
 			<name>permanent</name>
-			<classname>java.lang.String</classname>
+			<classname>boolean</classname>
 			<description>Attribute defines background should be permanent</description>
+			<defaultvalue>false</defaultvalue>
 		</property>
 		<property>
 			<name>reRenderAfterComplete</name>

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-01-10 12:14:17 UTC (rev 5257)
+++ trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java	2008-01-10 12:26:23 UTC (rev 5258)
@@ -104,9 +104,9 @@
     // TODO provide client script with percent value
     public String encodePersent(FacesContext context, UIComponent component)
 	    throws IOException {
-	String determinedAttr = (String) component.getAttributes().get(
+	Boolean determinedAttr = (Boolean) component.getAttributes().get(
 		"determined");
-	if (determinedAttr != null && "true".equals(determinedAttr)) {
+	if (determinedAttr != null && determinedAttr.booleanValue()) {
 	    String percent = getPercent(component);
 	    if (percent != null) {
 		return percent + "%";
@@ -155,9 +155,9 @@
 	String width = String.valueOf(value.intValue());
 	String percent = encodePersent(context, component);
 	String style = (String) component.getAttributes().get("style");
-	String permanent = (String) component.getAttributes().get("permanent");
+	Boolean permanent = (Boolean) component.getAttributes().get("permanent");
 
-	if (!(permanent != null && "true".equals(permanent))) {
+	if (!(permanent != null && permanent.booleanValue())) {
 
 	    String completeClass = (component.getAttributes().get(
 		    "completeClass") != null) ? (String) component

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-01-10 12:14:17 UTC (rev 5257)
+++ trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/js/progressBar.js	2008-01-10 12:26:23 UTC (rev 5258)
@@ -23,6 +23,8 @@
 			if (val.indexOf("%") < 0)
 				val = val + "%";
 		}
+		if (p > 100)  { this.switchMode("completed"); return; }
+		
 		if ($(this.id + ":progressState") != null)
 		{
 			if (this.mode == "progress")

Modified: trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx	2008-01-10 12:14:17 UTC (rev 5257)
+++ trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx	2008-01-10 12:26:23 UTC (rev 5258)
@@ -18,7 +18,10 @@
 	<jsp:scriptlet>
 <![CDATA[
     String mode = (String) component.getAttributes().get("mode");
-    boolean isAjax = !(mode != null && "client".equalsIgnoreCase(mode));
+    if (!mode.equalsIgnoreCase("client") && !mode.equalsIgnoreCase("ajax")) {
+    	throw new IOException("Mode attribute should have 'client' or 'ajax' value");
+    }
+    boolean isAjax = ("ajax".equalsIgnoreCase(mode));
     Boolean enabled = (Boolean) component.getAttributes().get("enabled");
     Number value = (Number)component.getAttributes().get("value");
     Integer percent = value.intValue();

Modified: trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java
===================================================================
--- trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java	2008-01-10 12:14:17 UTC (rev 5257)
+++ trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java	2008-01-10 12:26:23 UTC (rev 5258)
@@ -49,8 +49,7 @@
 	progressBar.setId("prgs");
 	progressBar.setValue(50);
 	progressBar.setInterval(1000);
-	progressBar.getAttributes().put("determined", "true");
-
+	
 	form.getChildren().add(progressBar);
 
     }




More information about the richfaces-svn-commits mailing list