[richfaces-svn-commits] JBoss Rich Faces SVN: r15276 - in root/ui/trunk/components/core/src/main: templates/org/ajax4jsf/renderkit/html and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Aug 24 10:16:02 EDT 2009


Author: abelevich
Date: 2009-08-24 10:16:01 -0400 (Mon, 24 Aug 2009)
New Revision: 15276

Modified:
   root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
   root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
Log:
fix NPE then attribute value null

Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java	2009-08-24 13:37:39 UTC (rev 15275)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java	2009-08-24 14:16:01 UTC (rev 15276)
@@ -26,6 +26,7 @@
 import javax.faces.application.ResourceDependencies;
 import javax.faces.application.ResourceDependency;
 import javax.faces.component.UIComponent;
+import javax.faces.component.ValueHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.event.ActionEvent;
 
@@ -83,29 +84,51 @@
 		}
 		return onClick.toString();
 	}
-//
-//	public void encodeChildren(FacesContext context, UIComponent component)
-//			throws IOException {
-//		renderChildren(context, component);
-//	}
-//
-//	public Object getValue(UIComponent uiComponent) {
-//		if (uiComponent instanceof ValueHolder) {
-//			return ((ValueHolder) uiComponent).getValue();
-//		}
-//		return uiComponent.getAttributes().get("value");
-//	}
-//
-//	public String getType(UIComponent uiComponent) {
-//		String type;
-//		if (uiComponent instanceof HtmlCommandButton) {
-//			type = ((HtmlCommandButton) uiComponent).getType();
-//		} else {
-//			type = (String) uiComponent.getAttributes().get("type");
-//		}
-//		if (type == null) {
-//			type = "button";
-//		}
-//		return type;
-//	}
+	 
+	public String getStringValue(UIComponent component) {
+		Object value = getValue(component);
+		return convertToString(value);
+	}
+	
+	protected String convertToString(Object obj ) {
+		return ( obj == null ? "" : obj.toString() );
+	}
+	
+	protected String convertToString(boolean b ) {
+		return String.valueOf(b);
+	}
+	
+	protected String convertToString(int b ) {
+		return b!=Integer.MIN_VALUE?String.valueOf(b):"";
+	}
+	
+	protected String convertToString(long b ) {
+		return b!=Long.MIN_VALUE?String.valueOf(b):"";
+	}
+/*
+	public void encodeChildren(FacesContext context, UIComponent component)
+			throws IOException {
+		renderChildren(context, component);
+	} */
+
+	public Object getValue(UIComponent component) {
+		if (component instanceof ValueHolder) {
+			return ((ValueHolder) component).getValue();
+		}
+		return component.getAttributes().get("value");
+	}
+
+	/*	
+	public String getType(UIComponent uiComponent) {
+		String type;
+		if (uiComponent instanceof HtmlCommandButton) {
+			type = ((HtmlCommandButton) uiComponent).getType();
+		} else {
+			type = (String) uiComponent.getAttributes().get("type");
+		}
+		if (type == null) {
+			type = "button";
+		}
+		return type;
+	}*/
 }

Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml	2009-08-24 13:37:39 UTC (rev 15275)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml	2009-08-24 14:16:01 UTC (rev 15276)
@@ -15,7 +15,7 @@
 		href="#"
 		class="#{component.attributes['styleClass']}"
 		>
-		#{component.attributes['value']}
+		#{this.getStringValue(component)}
 		<cdk:body>
 			<cdk:call expression="renderChildren(context,component);" />
 		</cdk:body>



More information about the richfaces-svn-commits mailing list