[richfaces-svn-commits] JBoss Rich Faces SVN: r12114 - in trunk/ui/inplaceSelect/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Jan 5 13:11:01 EST 2009


Author: abelevich
Date: 2009-01-05 13:11:01 -0500 (Mon, 05 Jan 2009)
New Revision: 12114

Modified:
   trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
   trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
   trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
Log:
fix empty default label bug: widget have disappeared after changed state if no item is selected and  defaultLabel == ""

Modified: trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
--- trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java	2009-01-05 17:39:07 UTC (rev 12113)
+++ trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java	2009-01-05 18:11:01 UTC (rev 12114)
@@ -107,6 +107,35 @@
 	return parentList;
     }
     
+    public String encodeScriptAttributes(FacesContext context, UIComponent component) {
+    	StringBuilder attributes = new StringBuilder();
+    	attributes.append("var attributes = ");
+    	
+    	ScriptOptions options = new ScriptOptions(component);
+    	
+    	String defaultLabel = (String)component.getAttributes().get("defaultLabel");
+
+    	if (defaultLabel == null || defaultLabel.trim().equals("")) {
+	    defaultLabel = EMPTY_DEFAULT_LABEL;
+    	}
+    	
+    	options.addOption("defaultLabel", defaultLabel);
+    	options.addOption("showControls");
+    	options.addOption("editEvent");
+    	options.addOption("verticalPosition", component.getAttributes().get("controlsVerticalPosition"));
+    	options.addOption("horizontalPosition", component.getAttributes().get("controlsHorizontalPosition"));
+    	options.addOption("inputWidth",component.getAttributes().get("selectWidth") );
+    	options.addOption("minInputWidth", component.getAttributes().get("minSelectWidth"));
+    	options.addOption("maxInputWidth", component.getAttributes().get("maxSelectWidth") );
+    	options.addOption("openOnEdit");
+    	options.addOption("showValueInView");
+    	options.addOption("closeOnSelect", true);
+
+    	attributes.append(options.toScript());
+    	  	
+    	return attributes.toString();
+    }
+    
     public void encodeControlsFacet(FacesContext context, UIComponent component) throws IOException {
 	UIComponent facet = component.getFacet(CONTROLS_FACET);
 	if ((facet != null) && (facet.isRendered())) {
@@ -159,7 +188,7 @@
     
     protected String createDefaultLabel(UIComponent component) {
 	String defaultLabel = (String) component.getAttributes().get("defaultLabel");
-	if (defaultLabel == null || defaultLabel.length() == 0) {
+	if (defaultLabel == null || defaultLabel.trim().equals("")) {
 	    defaultLabel = EMPTY_DEFAULT_LABEL;
 	}
 	return defaultLabel;

Modified: trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js
===================================================================
--- trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js	2009-01-05 17:39:07 UTC (rev 12113)
+++ trunk/ui/inplaceSelect/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceselect.js	2009-01-05 18:11:01 UTC (rev 12114)
@@ -185,7 +185,7 @@
 				var unescapedValue = this.currentItemValue;
 			//	var params = {itemValue: unescapedValue,itemLabel: this.tempValueKeeper.value}
 //				var unescapeText = this.tempValueKeeper.value.unescapeHTML();
-				this.setValue(e,unescapedValue);
+				this.setValue(unescapedValue);
 		}
 	},
 	

Modified: trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
===================================================================
--- trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx	2009-01-05 17:39:07 UTC (rev 12113)
+++ trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx	2009-01-05 18:11:01 UTC (rev 12114)
@@ -227,8 +227,8 @@
 			
 			
 			<script type="text/javascript">
-				
-				
+				#{this:encodeScriptAttributes(context, component)};
+								
 				var inplaceSelectUserStyles = {
 					
 					combolist: {
@@ -250,17 +250,7 @@
 															'#{clientId}inplaceTmpValue', '#{clientId}shadow', 0, 0, #{encodedFieldValue}), 
 															'#{clientId}', '#{clientId}inplaceTmpValue', 
 															'#{clientId}inplaceValue', '#{clientId}tabber',
-															{defaultLabel : '#{component.attributes["defaultLabel"]}', 
-															showControls : #{component.attributes["showControls"]},
-															editEvent : '#{component.attributes["editEvent"]}',
-															verticalPosition : '#{component.attributes["controlsVerticalPosition"]}',
-															horizontalPosition : '#{component.attributes["controlsHorizontalPosition"]}',
-															inputWidth : '#{component.attributes["selectWidth"]}',
-															minInputWidth : '#{component.attributes["minSelectWidth"]}',
-															maxInputWidth : '#{component.attributes["maxSelectWidth"]}',
-															openOnEdit: #{component.attributes["openOnEdit"]},
-															showValueInView: #{component.attributes["showValueInView"]}, 
-															closeOnSelect: true},
+															attributes,
 															{oneditactivation : #{this:getAsEventHandler(context, component, "oneditactivation")}, 
 															onviewactivation : #{this:getAsEventHandler(context, component, "onviewactivation")}, 
 															oneditactivated : #{this:getAsEventHandler(context, component, "oneditactivated")}, 




More information about the richfaces-svn-commits mailing list