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/09/18 03:51:08 UTC

svn commit: r816431 - in /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html: HTML.java HtmlBodyRendererBase.java

Author: lu4242
Date: Fri Sep 18 01:51:08 2009
New Revision: 816431

URL: http://svn.apache.org/viewvc?rev=816431&view=rev
Log:
MYFACES-2228 move body renderer to shared

Added:
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java   (with props)
Modified:
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java?rev=816431&r1=816430&r2=816431&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java Fri Sep 18 01:51:08 2009
@@ -435,6 +435,34 @@
             UL_ATTRIBUTES,
             COMMON_PASSTROUGH_ATTRIBUTES);
 
+    //body
+    String BODY_ELEM = "body";
+    String BODY_TARGET = BODY_ELEM;
+    
+    String ONLOAD_ATTR = "onload";
+    String ONUNLOAD_ATTR = "onload";
+    String ALINK_ATTR = "alink";
+    String VLINK_ATTR = "vlink";
+    String LINK_ATTR = "link";
+    String TEXT_ATTR = "text";
+    String BACKGROUND_ATTR = "background";
+
+    String[] BODY_ATTRIBUTES =
+    {
+        ONLOAD_ATTR,
+        ONUNLOAD_ATTR,
+        ALINK_ATTR,
+        VLINK_ATTR,
+        LINK_ATTR,
+        TEXT_ATTR,
+        BACKGROUND_ATTR,
+        HTML.BGCOLOR_ATTR
+    };
+
+    String[] BODY_PASSTHROUGH_ATTRIBUTES =
+        (String[]) ArrayUtils.concat(
+                COMMON_PASSTROUGH_ATTRIBUTES,
+                BODY_ATTRIBUTES);
 
     //HTML attributes needed for renderding only
     String ID_ATTR = "id";

Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java?rev=816431&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java Fri Sep 18 01:51:08 2009
@@ -0,0 +1,66 @@
+/*
+ * 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.shared.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;
+
+/**
+ * Renderer used by h:body component
+ * 
+ * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class HtmlBodyRendererBase extends HtmlRenderer
+{
+
+    @Override
+    public void encodeBegin(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeBegin(facesContext, component); //check for NP
+
+        ResponseWriter writer = facesContext.getResponseWriter();
+        writer.startElement(HTML.BODY_ELEM, component);
+        HtmlRendererUtils.writeIdIfNecessary(writer, component, facesContext);
+        HtmlRendererUtils.renderHTMLAttributes(writer, component,
+                HTML.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,
+                HTML.BODY_TARGET))
+        {
+            child.encodeAll(facesContext);
+        }
+        writer.endElement(HTML.BODY_ELEM);
+    }
+}

Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlBodyRendererBase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL