[richfaces-svn-commits] JBoss Rich Faces SVN: r11998 - trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Dec 23 12:22:54 EST 2008


Author: vmolotkov
Date: 2008-12-23 12:22:53 -0500 (Tue, 23 Dec 2008)
New Revision: 11998

Modified:
   trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
Log:
https://jira.jboss.org/jira/browse/RF-5104

Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java	2008-12-23 16:54:44 UTC (rev 11997)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java	2008-12-23 17:22:53 UTC (rev 11998)
@@ -25,8 +25,10 @@
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 import javax.faces.FacesException;
 import javax.faces.application.ViewHandler;
@@ -66,9 +68,12 @@
 	 * Substitutions for components properies names and HTML attributes names.
 	 */
 	private static Map<String, String> substitutions = new HashMap<String, String>();
+	
+	private static Set<String> requiredAttributes = new HashSet<String>();
 
 	static {
 		substitutions.put(HTML.class_ATTRIBUTE, "styleClass");
+		requiredAttributes.add(HTML.alt_ATTRIBUTE);
 		Arrays.sort(HTML.PASS_THRU);
 		Arrays.sort(HTML.PASS_THRU_BOOLEAN);
 		Arrays.sort(HTML.PASS_THRU_URI);
@@ -387,7 +392,7 @@
 			ResponseWriter writer, String attribute) throws IOException {
 		Object value = attributeValue(attribute, attributes
 				.get(getComponentAttributeName(attribute)));
-		if (null != value && shouldRenderAttribute(value)) {
+		if (null != value && shouldRenderAttribute(attribute, value)) {
 			if (Arrays.binarySearch(HTML.PASS_THRU_URI, attribute) >= 0) {
 				String url = context.getApplication().getViewHandler()
 						.getResourceURL(context, value.toString());
@@ -439,7 +444,7 @@
 			Object property, String attributeName) throws IOException {
 		ResponseWriter writer = context.getResponseWriter();
 		Object value = component.getAttributes().get(property);
-		if (shouldRenderAttribute(value)) {
+		if (shouldRenderAttribute(attributeName, value)) {
 			writer.writeAttribute(attributeName, value, property.toString());
 		}
 
@@ -461,7 +466,7 @@
 	 */
 	public void writeAttribute(ResponseWriter writer, String attribute,
 			Object value) throws IOException {
-		if (shouldRenderAttribute(value)) {
+		if (shouldRenderAttribute(attribute, value)) {
 			writer.writeAttribute(attribute, value.toString(), attribute);
 		}
 	}
@@ -484,6 +489,17 @@
 		} else
 			return isValidProperty(attributeVal);
 	}
+	
+	public boolean shouldRenderAttribute(String attributeName, Object attributeVal) {
+		if (!requiredAttributes.contains(attributeName)) {
+			shouldRenderAttribute(attributeVal);
+		} else {
+			if (null == attributeVal) {
+				return false;
+			}
+		}
+		return true;
+	}
 
 	/**
 	 * Test for valid value of property. by default, for non-setted properties




More information about the richfaces-svn-commits mailing list