You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by id...@apache.org on 2007/05/14 11:12:26 UTC

svn commit: r537758 - /myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java

Author: idus
Date: Mon May 14 02:12:25 2007
New Revision: 537758

URL: http://svn.apache.org/viewvc?view=rev&rev=537758
Log:
TOBAGO-398: readded favicon support

Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?view=diff&rev=537758&r1=537757&r2=537758
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Mon May 14 02:12:25 2007
@@ -47,6 +47,7 @@
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.util.AccessKeyMap;
 import org.apache.myfaces.tobago.util.ResponseUtils;
+import org.apache.myfaces.tobago.util.MimeTypeUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.application.Application;
@@ -197,6 +198,29 @@
           writer.endElement(HtmlConstants.LINK);
         }
       }
+    }
+
+    String icon = page.getApplicationIcon();
+    if (icon != null) {
+      // XXX unify with image renderer
+      if (icon.startsWith("HTTP:") || icon.startsWith("FTP:")
+          || icon.startsWith("/")) {
+        // absolute Path to image : nothing to do
+      } else {
+        icon = ResourceManagerUtil.getImageWithPath(facesContext, icon);
+      }
+
+      writer.startElement(HtmlConstants.LINK, null);
+      if (icon.endsWith(".ico")) {
+        writer.writeAttribute(HtmlAttributes.REL, "shortcut icon", false);
+        writer.writeAttribute(HtmlAttributes.HREF, icon, false);
+      } else {
+        // XXX IE only supports ICO files for favicons
+        writer.writeAttribute(HtmlAttributes.REL, "icon", false);
+        writer.writeAttribute(HtmlAttributes.TYPE, MimeTypeUtils.getMimeTypeForFile(icon), false);
+        writer.writeAttribute(HtmlAttributes.HREF, icon, false);
+      }
+      writer.endElement(HtmlConstants.LINK);
     }
 
     // style sniplets