myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cjhow...@apache.org
Subject svn commit: r805757 - in /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit: JSFAttr.java html/HtmlImageRendererBase.java
Date Wed, 19 Aug 2009 11:37:51 GMT
Author: cjhoward
Date: Wed Aug 19 11:37:51 2009
New Revision: 805757

URL: http://svn.apache.org/viewvc?rev=805757&view=rev
Log:
MYFACES-2330 - h:graphicImage needs to render "name" attribute.

Modified:
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java?rev=805757&r1=805756&r2=805757&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
Wed Aug 19 11:37:51 2009
@@ -111,6 +111,7 @@
     String TOOLTIP_ATTR                = "tooltip";
 
     // GraphicImage attributes
+    String NAME_ATTR                   = "name";
     String URL_ATTR                    = "url";
 
     // UISelectItem attributes

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java?rev=805757&r1=805756&r2=805757&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
Wed Aug 19 11:37:51 2009
@@ -22,6 +22,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.shared.renderkit.JSFAttr;
 
+import javax.faces.application.Resource;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIGraphic;
 import javax.faces.component.html.HtmlGraphicImage;
@@ -72,7 +73,23 @@
         }
         else
         {
-            if (log.isWarnEnabled()) log.warn("Graphic with id " + uiComponent.getClientId(facesContext)
+ " has no value (url).");
+            String name = (String) uiComponent.getAttributes().get (JSFAttr.NAME_ATTR);
+            
+            // JSF 2.0: if "name" attribute is available, treat as a resource reference.
+            
+            if ((name != null) && (name.length() > 0))
+            {
+                Resource resource = facesContext.getApplication().getResourceHandler().createResource
(name);
+                String src = resource.getRequestPath();
+                
+                writer.writeURIAttribute(HTML.SRC_ATTR,
+                    facesContext.getExternalContext().encodeResourceURL(src), JSFAttr.VALUE_ATTR);
+            }
+            
+            else
+            {
+                if (log.isWarnEnabled()) log.warn("Graphic with id " + uiComponent.getClientId(facesContext)
+ " has no value (url or name).");
+            }
         }
 
         /* 



Mime
View raw message