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/10 17:53:08 UTC
svn commit: r536893 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/servlet/
core/src/main/java/org/apache/myfaces/tobago/tag...
Author: idus
Date: Thu May 10 08:53:07 2007
New Revision: 536893
URL: http://svn.apache.org/viewvc?view=rev&rev=536893
Log:
TOBAGO-398: added preliminary support for favicons
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/servlet/ResourceServlet.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTag.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java?view=diff&rev=536893&r1=536892&r2=536893
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java Thu May 10 08:53:07 2007
@@ -168,6 +168,7 @@
public static final String ATTR_WIDTH = "width";
public static final String ATTR_WIDTH_LIST = "widthList";
public static final String ATTR_WIDTH_LIST_STRING = "widthListString";
+ public static final String ATTR_APPLICATION_ICON = "applicationIcon";
public static final String FACET_ACTION = "action";
public static final String FACET_CONFIRMATION = "confirmation";
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java?view=diff&rev=536893&r1=536892&r2=536893
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPage.java Thu May 10 08:53:07 2007
@@ -17,6 +17,7 @@
* limitations under the License.
*/
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_APPLICATION_ICON;
import org.apache.commons.collections.KeyValue;
import org.apache.commons.collections.list.SetUniqueList;
import org.apache.commons.collections.set.ListOrderedSet;
@@ -31,6 +32,7 @@
import org.apache.myfaces.tobago.model.PageState;
import org.apache.myfaces.tobago.model.PageStateImpl;
import org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataRequest;
+import org.apache.myfaces.tobago.TobagoConstants;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
@@ -89,6 +91,8 @@
private Integer height;
+ private String applicationIcon;
+
@SuppressWarnings({"unchecked"})
public UIPage() {
scriptFiles = SetUniqueList.decorate(new ArrayList());
@@ -403,6 +407,21 @@
this.height = height;
}
+ public String getApplicationIcon() {
+ if (applicationIcon != null) {
+ return applicationIcon;
+ }
+ ValueBinding vb = getValueBinding(ATTR_APPLICATION_ICON);
+ if (vb != null) {
+ return (String) vb.getValue(getFacesContext());
+ } else {
+ return null;
+ }
+ }
+
+ public void setApplicationIcon(String applicationIcon) {
+ this.applicationIcon = applicationIcon;
+ }
public void restoreState(FacesContext context, Object state) {
Object[] values = (Object[]) state;
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/servlet/ResourceServlet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/servlet/ResourceServlet.java?view=diff&rev=536893&r1=536892&r2=536893
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/servlet/ResourceServlet.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/servlet/ResourceServlet.java Thu May 10 08:53:07 2007
@@ -98,6 +98,8 @@
response.setContentType("text/javascript");
} else if (requestURI.endsWith(".css")) {
response.setContentType("text/css");
+ } else if (requestURI.endsWith(".ico")) {
+ response.setContentType("image/vnd.microsoft.icon");
} else {
LOG.warn("Unsupported file extension, will be ignored for security "
+ "reasons. resource='" + resource + "'");
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTag.java?view=diff&rev=536893&r1=536892&r2=536893
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTag.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTag.java Thu May 10 08:53:07 2007
@@ -17,6 +17,7 @@
* limitations under the License.
*/
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_APPLICATION_ICON;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DOCTYPE;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOCUS_ID;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
@@ -27,6 +28,7 @@
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.component.UIPage;
import org.apache.myfaces.tobago.component.UIPopup;
+import org.apache.myfaces.tobago.TobagoConstants;
import javax.faces.component.UIComponent;
import javax.servlet.jsp.JspException;
@@ -51,6 +53,8 @@
private String height;
+ private String applicationIcon;
+
public int doEndTag() throws JspException {
UIPage page = (UIPage) getComponentInstance();
List<UIPopup> popups = page.getPopups();
@@ -78,6 +82,7 @@
label = null;
width = null;
height = null;
+ applicationIcon = null;
}
protected void setProperties(UIComponent component) {
@@ -89,6 +94,7 @@
ComponentUtil.setValueBinding(component, ATTR_STATE, state);
ComponentUtil.setIntegerSizeProperty(component, ATTR_WIDTH, width);
ComponentUtil.setIntegerSizeProperty(component, ATTR_HEIGHT, height);
+ ComponentUtil.setStringProperty(component, ATTR_APPLICATION_ICON, applicationIcon);
}
public void setDoctype(String doctype) {
@@ -133,6 +139,14 @@
public void setHeight(String height) {
this.height = height;
+ }
+
+ public void setApplicationIcon(String icon) {
+ applicationIcon = icon;
+ }
+
+ public String getApplicationIcon() {
+ return applicationIcon;
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java?view=diff&rev=536893&r1=536892&r2=536893
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PageTagDeclaration.java Thu May 10 08:53:07 2007
@@ -49,28 +49,35 @@
public interface PageTagDeclaration extends TobagoBodyTagDeclaration, HasLabel, HasId, HasDimension, HasBinding,
HasState {
/**
- * values for doctype :
- * 'strict' : HTML 4.01 Strict DTD
- * 'loose' : HTML 4.01 Transitional DTD
- * 'frameset' : HTML 4.01 Frameset DTD
- * all other values are ignored and no DOCTYPE is set.
- * default value is 'loose'
- *
- * @param doctype
+ * Possible values for doctype are:
+ * <dl>
+ * <dt>strict</dt><dd>HTML 4.01 Strict DTD</dd>
+ * <dt>loose</dt><dd>HTML 4.01 Transitional DTD</dd>
+ * <dt>frameset</dt><dd>HTML 4.01 Frameset DTD</dd>
+ * </dl>
+ * All other values are ignored and no DOCTYPE is set.
+ * The default value is 'loose'.
*/
@TagAttribute
@UIComponentTagAttribute(defaultValue = "loose")
void setDoctype(String doctype);
/**
- * Contains the id of the component witch should have the focus after
+ * Contains the id of the component wich should have the focus after
* loading the page.
* Set to emtpy string for disabling setting of focus.
* Default (null) enables the "auto focus" feature.
- *
- * @param focusId
*/
@TagAttribute
@UIComponentTagAttribute()
void setFocusId(String focusId);
+
+ /**
+ * Absolute URL to an image or image name to lookup in tobago resource path
+ * representing the application. In HTML it is used as a favicon.
+ */
+ @TagAttribute
+ @UIComponentTagAttribute()
+ void setApplicationIcon(String icon);
+
}
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=536893&r1=536892&r2=536893
==============================================================================
--- 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 Thu May 10 08:53:07 2007
@@ -198,6 +198,22 @@
}
}
}
+ 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);
+ }
+ // For non-ICO files perhaps generate something like this:
+ // <link rel="icon" type="image/png" href="/favicon.png">
+ writer.startElement(HtmlConstants.LINK, null);
+ writer.writeAttribute(HtmlAttributes.REL, "shortcut icon", null);
+ writer.writeAttribute(HtmlAttributes.HREF, icon, null);
+ writer.endElement(HtmlConstants.LINK);
+ }
// style sniplets
Set<String> styleBlocks = page.getStyleBlocks();