You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/05/08 01:28:58 UTC

svn commit: r772811 - in /myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html: HtmlBodyRenderer.java HtmlHeadRenderer.java HtmlScriptRenderer.java HtmlStylesheetRenderer.java

Author: lu4242
Date: Thu May  7 23:28:57 2009
New Revision: 772811

URL: http://svn.apache.org/viewvc?rev=772811&view=rev
Log:
MYFACES-2228 Add h:head, h:body, h:outputScript and h:outputStylesheet renderers

Added:
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java   (with props)
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java   (with props)
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java   (with props)
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java   (with props)

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java?rev=772811&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java Thu May  7 23:28:57 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.shared_impl.renderkit.html.HTML;
+import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared_impl.util.ArrayUtils;
+
+/**
+ * Renderer used by h:body component
+ * 
+ * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@JSFRenderer(renderKitId = "HTML_BASIC", family = "javax.faces.Output", type = "javax.faces.Body")
+public class HtmlBodyRenderer extends Renderer
+{
+    //TODO: Move constants to shared HTML class
+    private final static String BODY_ELEM = "body";
+    private final static String BODY_TARGET = BODY_ELEM;
+    
+    private final static String ONLOAD_ATTR = "onload";
+    private final static String ONUNLOAD_ATTR = "onload";
+    private final static String ALINK_ATTR = "alink";
+    private final static String VLINK_ATTR = "vlink";
+    private final static String LINK_ATTR = "link";
+    private final static String TEXT_ATTR = "text";
+    private final static String BACKGROUND_ATTR = "background";
+
+    private final static String[] BODY_ATTRIBUTES =
+    {
+        ONLOAD_ATTR,
+        ONUNLOAD_ATTR,
+        ALINK_ATTR,
+        VLINK_ATTR,
+        LINK_ATTR,
+        TEXT_ATTR,
+        BACKGROUND_ATTR,
+        HTML.BGCOLOR_ATTR
+    };
+
+    private final static String[] BODY_PASSTHROUGH_ATTRIBUTES =
+        (String[]) ArrayUtils.concat(
+                HTML.COMMON_PASSTROUGH_ATTRIBUTES,
+                BODY_ATTRIBUTES);
+    @Override
+    public void encodeBegin(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeBegin(facesContext, component); //check for NP
+
+        ResponseWriter writer = facesContext.getResponseWriter();
+        writer.startElement(BODY_ELEM, component);
+        HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
+        HtmlRendererUtils.renderHTMLAttributes(writer, component,
+                BODY_PASSTHROUGH_ATTRIBUTES);
+    }
+
+    @Override
+    public void encodeEnd(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeEnd(facesContext, component); //check for NP
+
+        ResponseWriter writer = facesContext.getResponseWriter();
+        UIViewRoot root = facesContext.getViewRoot();
+        for (UIComponent child : root.getComponentResources(facesContext,
+                BODY_TARGET))
+        {
+            child.encodeAll(facesContext);
+        }
+        writer.endElement(BODY_ELEM);
+    }
+}

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlBodyRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java?rev=772811&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java Thu May  7 23:28:57 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.shared_impl.renderkit.html.HTML;
+import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils;
+
+/**
+ * Renderer used by h:head component
+ * 
+ * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@JSFRenderer(renderKitId = "HTML_BASIC", family = "javax.faces.Output", type = "javax.faces.Head")
+public class HtmlHeadRenderer extends Renderer
+{
+    //TODO: Move constants to shared HTML class
+    private final static String HEAD_ELEM = "head";
+    private final static String HEAD_TARGET = HEAD_ELEM;
+
+    private final static String PROFILE_ATTR = "profile";
+
+    private final static String[] HEAD_PASSTHROUGH_ATTRIBUTES = { HTML.DIR_ATTR,
+            HTML.LANG_ATTR, PROFILE_ATTR};
+
+    @Override
+    public void encodeBegin(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeBegin(facesContext, component); //check for NP
+
+        ResponseWriter writer = facesContext.getResponseWriter();
+        writer.startElement(HEAD_ELEM, component);
+        HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
+        HtmlRendererUtils.renderHTMLAttributes(writer, component,
+                HEAD_PASSTHROUGH_ATTRIBUTES);
+    }
+
+    @Override
+    public void encodeEnd(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeEnd(facesContext, component); //check for NP
+
+        ResponseWriter writer = facesContext.getResponseWriter();
+        UIViewRoot root = facesContext.getViewRoot();
+        for (UIComponent child : root.getComponentResources(facesContext,
+                HEAD_TARGET))
+        {
+            child.encodeAll(facesContext);
+        }
+        writer.endElement(HEAD_ELEM);
+    }
+}

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHeadRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java?rev=772811&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java Thu May  7 23:28:57 2009
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.application.ProjectStage;
+import javax.faces.application.Resource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PostAddToViewEvent;
+import javax.faces.render.Renderer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
+import org.apache.myfaces.shared_impl.renderkit.html.HTML;
+
+/**
+ * Renderer used by h:outputScript component
+ * 
+ * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@JSFRenderer(renderKitId = "HTML_BASIC", family = "javax.faces.Output", type = "javax.faces.resource.Script")
+@ListenerFor(systemEventClass = PostAddToViewEvent.class)
+public class HtmlScriptRenderer extends Renderer implements
+        ComponentSystemEventListener
+{
+    private static final Log log = LogFactory.getLog(HtmlScriptRenderer.class);
+    
+    private final static String RENDERED_RESOURCES_SET = HtmlScriptRenderer.class+".RENDERED_RESOURCES_SET"; 
+
+    @Override
+    public void processEvent(ComponentSystemEvent event)
+    {
+        UIComponent component = event.getComponent();
+        String target = (String) component.getAttributes().get("target");
+        if (target != null)
+        {
+            FacesContext facesContext = FacesContext.getCurrentInstance();
+            facesContext.getViewRoot().addComponentResource(facesContext,
+                    component, target);
+        }
+    }
+
+    @Override
+    public boolean getRendersChildren()
+    {
+        return true;
+    }
+
+    /**
+     * Return a set of already rendered resources by this renderer on the current
+     * request. 
+     * 
+     * @param facesContext
+     * @return
+     */
+    protected Set<String> getRenderedResources(FacesContext facesContext)
+    {
+        Set<String> map = (Set<String>) facesContext.getAttributes().get(RENDERED_RESOURCES_SET);
+        if (map == null)
+        {
+            map = new HashSet<String>();
+            facesContext.getAttributes().put(RENDERED_RESOURCES_SET,map);
+        }
+        return map;
+    }
+    
+    @Override
+    public void encodeChildren(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        if (facesContext == null)
+            throw new NullPointerException("context");
+        if (component == null)
+            throw new NullPointerException("component");
+
+        Map<String, Object> componentAttributesMap = component.getAttributes();
+        String resourceName = (String) componentAttributesMap.get("name");
+        boolean hasChildren = component.getChildCount() > 0;
+        
+        if (resourceName != null && (!"".equals(resourceName)) )
+        {
+            if (hasChildren)
+            {
+                log.info("Component with resourceName "+ resourceName + 
+                        " and child components found. Child components will be ignored.");
+            }
+        }
+        else
+        {
+            if (hasChildren)
+            {
+                // Children are encoded as usual. Usually the layout is
+                // <script type="text/javascript">
+                // ...... some javascript .......
+                // </script>
+                ResponseWriter writer = facesContext.getResponseWriter();
+                writer.startElement(HTML.SCRIPT_ELEM, component);
+                writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+                RendererUtils.renderChildren(facesContext, component);
+                writer.endElement(HTML.SCRIPT_ELEM);
+            }
+            else
+            {
+                if (!facesContext.getApplication().getProjectStage().equals(
+                        ProjectStage.Production))
+                {
+                    facesContext.addMessage(component.getClientId(), 
+                            new FacesMessage("Component with no name and no body content, so nothing rendered."));
+                }
+            }            
+        }
+    }
+
+    @Override
+    public void encodeEnd(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeEnd(facesContext, component); //check for NP
+        
+        Map<String, Object> componentAttributesMap = component.getAttributes();
+        String resourceName = (String) componentAttributesMap.get("name");
+        String libraryName = (String) componentAttributesMap.get("library");
+
+        if (resourceName == null)
+        {
+            //log.warn("Trying to encode resource represented by component" + 
+            //        component.getClientId() + " without resourceName."+
+            //        " It will be silenty ignored.");
+            return;
+        }
+        if ("".equals(resourceName))
+        {
+            return;
+        }
+        
+        Set<String> renderedResources = getRenderedResources(facesContext);
+                
+        String resourceKey;
+        Resource resource;
+        if (libraryName == null)
+        {
+            resourceKey = resourceName;
+            if (renderedResources.contains(resourceKey))
+            {
+                //Resource already founded
+                return;
+            }
+            resource = facesContext.getApplication().getResourceHandler()
+                    .createResource(resourceName);
+        }
+        else
+        {
+            resourceKey = libraryName+'/'+resourceName;
+            if (renderedResources.contains(resourceKey))
+            {
+                //Resource already founded
+                return;
+            }
+            resource = facesContext.getApplication().getResourceHandler()
+                    .createResource(resourceName, libraryName);
+
+        }
+        
+        if (resource == null)
+        {
+            //no resource found
+            log.warn("Resource referenced by resourceName "+ resourceName +
+                    (libraryName == null ? "" : " and libraryName " + libraryName) +
+                    " not found in call to ResourceHandler.createResource."+
+                    " It will be silenty ignored.");
+            return;
+        }
+        else
+        {
+            // Rendering resource
+            renderedResources.add(resourceKey);
+            ResponseWriter writer = facesContext.getResponseWriter();
+            writer.startElement(HTML.SCRIPT_ELEM, component);
+            writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, 
+                    (resource.getContentType() == null ? HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT
+                            : resource.getContentType()) , null);
+            writer.writeURIAttribute(HTML.SRC_ATTR, resource.getRequestPath(), null);
+            writer.endElement(HTML.SCRIPT_ELEM);
+        }
+    }
+}

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java?rev=772811&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java Thu May  7 23:28:57 2009
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.application.ProjectStage;
+import javax.faces.application.Resource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PostAddToViewEvent;
+import javax.faces.render.Renderer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
+import org.apache.myfaces.shared_impl.renderkit.html.HTML;
+
+/**
+ * Renderer used by h:outputStylesheet component
+ * 
+ * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@JSFRenderer(renderKitId = "HTML_BASIC", family = "javax.faces.Output", type = "javax.faces.resource.Stylesheet")
+@ListenerFor(systemEventClass = PostAddToViewEvent.class)
+public class HtmlStylesheetRenderer extends Renderer implements
+    ComponentSystemEventListener
+{
+    private static final Log log = LogFactory.getLog(HtmlStylesheetRenderer.class);
+    
+    private final static String RENDERED_RESOURCES_SET = HtmlStylesheetRenderer.class+".RENDERED_RESOURCES_SET"; 
+
+    @Override
+    public void processEvent(ComponentSystemEvent event)
+    {
+        UIComponent component = event.getComponent();
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        facesContext.getViewRoot().addComponentResource(facesContext,
+                    component, "head");
+    }
+
+    @Override
+    public boolean getRendersChildren()
+    {
+        return true;
+    }
+
+    /**
+     * Return a set of already rendered resources by this renderer on the current
+     * request. 
+     * 
+     * @param facesContext
+     * @return
+     */
+    protected Set<String> getRenderedResources(FacesContext facesContext)
+    {
+        Set<String> map = (Set<String>) facesContext.getAttributes().get(RENDERED_RESOURCES_SET);
+        if (map == null)
+        {
+            map = new HashSet<String>();
+            facesContext.getAttributes().put(RENDERED_RESOURCES_SET,map);
+        }
+        return map;
+    }
+    
+    @Override
+    public void encodeChildren(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        if (facesContext == null)
+            throw new NullPointerException("context");
+        if (component == null)
+            throw new NullPointerException("component");
+
+        Map<String, Object> componentAttributesMap = component.getAttributes();
+        String resourceName = (String) componentAttributesMap.get("name");
+        boolean hasChildren = component.getChildCount() > 0;
+        
+        if (resourceName != null && (!"".equals(resourceName)) )
+        {
+            if (hasChildren)
+            {
+                log.info("Component with resourceName "+ resourceName + 
+                        " and child components found. Child components will be ignored.");
+            }
+        }
+        else
+        {
+            if (hasChildren)
+            {
+                ResponseWriter writer = facesContext.getResponseWriter();
+                writer.startElement(HTML.STYLE_ELEM, component);
+                writer.writeAttribute(HTML.TYPE_ATTR, HTML.STYLE_TYPE_TEXT_CSS, null);
+                RendererUtils.renderChildren(facesContext, component);
+                writer.endElement(HTML.STYLE_ELEM);
+            }
+            else
+            {
+                if (!facesContext.getApplication().getProjectStage().equals(
+                        ProjectStage.Production))
+                {
+                    facesContext.addMessage(component.getClientId(), 
+                            new FacesMessage("Component with no name and no body content, so nothing rendered."));
+                }
+            }            
+        }
+    }
+    
+    @Override
+    public void encodeEnd(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeEnd(facesContext, component); //check for NP
+        
+        Map<String, Object> componentAttributesMap = component.getAttributes();
+        String resourceName = (String) componentAttributesMap.get("name");
+        String libraryName = (String) componentAttributesMap.get("library");
+
+        if (resourceName == null)
+        {
+            //log.warn("Trying to encode resource represented by component" + 
+            //        component.getClientId() + " without resourceName."+
+            //        " It will be silenty ignored.");
+            return;
+        }
+        if ("".equals(resourceName))
+        {
+            return;
+        }
+        
+        Set<String> renderedResources = getRenderedResources(facesContext);
+                
+        String resourceKey;
+        Resource resource;
+        if (libraryName == null)
+        {
+            resourceKey = resourceName;
+            if (renderedResources.contains(resourceKey))
+            {
+                //Resource already founded
+                return;
+            }
+            resource = facesContext.getApplication().getResourceHandler()
+                    .createResource(resourceName);
+        }
+        else
+        {
+            resourceKey = libraryName+'/'+resourceName;
+            if (renderedResources.contains(resourceKey))
+            {
+                //Resource already founded
+                return;
+            }
+            resource = facesContext.getApplication().getResourceHandler()
+                    .createResource(resourceName, libraryName);
+
+        }
+        
+        if (resource == null)
+        {
+            //no resource found
+            log.warn("Resource referenced by resourceName "+ resourceName +
+                    (libraryName == null ? "" : " and libraryName " + libraryName) +
+                    " not found in call to ResourceHandler.createResource."+
+                    " It will be silenty ignored.");
+            return;
+        }
+        else
+        {
+            // Rendering resource
+            renderedResources.add(resourceKey);
+            ResponseWriter writer = facesContext.getResponseWriter();
+            writer.startElement(HTML.LINK_ELEM, component);
+            writer.writeAttribute(HTML.REL_ATTR, HTML.STYLESHEET_VALUE,null );
+            writer.writeAttribute("media", "screen",null );            
+            writer.writeAttribute(HTML.TYPE_ATTR, 
+                    (resource.getContentType() == null ? HTML.STYLE_TYPE_TEXT_CSS
+                            : resource.getContentType()) , null);
+            writer.writeURIAttribute(HTML.HREF_ATTR, resource.getRequestPath(), null);
+            writer.endElement(HTML.LINK_ELEM);
+        }
+    }
+}

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL