myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1772152 - in /myfaces/tobago/trunk/tobago-core/src: main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ main/java/org/apache/myfaces/tobago/internal/webapp/ test/java/org/apache/myfaces/tobago/webapp/
Date Thu, 01 Dec 2016 08:29:10 GMT
Author: lofwyr
Date: Thu Dec  1 08:29:10 2016
New Revision: 1772152

URL: http://svn.apache.org/viewvc?rev=1772152&view=rev
Log:
TOBAGO-1368: The standard theme will use Bootstrap
* move the rendering of the HTML tag from the ResponseWriter to the PageRenderer, to have
the possibility to add CSS to the HTML Tag. In general this is not needed, but for some special
e.g. height: 100%

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/HtmlResponseWriter.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java?rev=1772152&r1=1772151&r2=1772152&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
Thu Dec  1 08:29:10 2016
@@ -65,6 +65,7 @@ import javax.servlet.http.HttpServletRes
 import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 // currently using tobago-jsf.js instead
@@ -153,7 +154,8 @@ public class PageRenderer extends Render
     final Object response = externalContext.getResponse();
     final Application application = facesContext.getApplication();
     final ViewHandler viewHandler = application.getViewHandler();
-    final String viewId = facesContext.getViewRoot().getViewId();
+    final UIViewRoot viewRoot = facesContext.getViewRoot();
+    final String viewId = viewRoot.getViewId();
     final String formAction = externalContext.encodeActionURL(viewHandler.getActionURL(facesContext,
viewId));
     final String partialAction;
     final boolean portlet = PortletUtils.isPortletApiAvailable() && response instanceof
MimeResponse;
@@ -194,6 +196,17 @@ public class PageRenderer extends Render
     if (!facesContext.getPartialViewContext().isAjaxRequest()) {
       final String title = page.getLabel();
 
+      if (!PortletUtils.isPortletApiAvailable() || !(response instanceof MimeResponse)) {
+        writer.startElement(HtmlElements.HTML);
+        final Locale locale = viewRoot.getLocale();
+        if (locale != null) {
+          final String language = locale.getLanguage();
+          if (language != null) {
+            writer.writeAttribute(HtmlAttributes.LANG, language, false);
+          }
+        }
+      }
+
       writer.startElement(HtmlElements.HEAD);
 
       // meta tags
@@ -241,8 +254,7 @@ public class PageRenderer extends Render
         }
         writer.endElement(HtmlElements.LINK);
       }
-      UIViewRoot root = facesContext.getViewRoot();
-      List<UIComponent> componentResources = root.getComponentResources(facesContext,
HEAD_TARGET);
+      List<UIComponent> componentResources = viewRoot.getComponentResources(facesContext,
HEAD_TARGET);
 
       for (int i = 0, childCount = componentResources.size(); i < childCount; i++) {
         UIComponent child = componentResources.get(i);
@@ -381,7 +393,6 @@ public class PageRenderer extends Render
     }
     writer.endElement(HtmlElements.SPAN);
 
-
     writer.endElement(HtmlElements.FORM);
 
     writer.startElement(HtmlElements.NOSCRIPT);
@@ -396,6 +407,7 @@ public class PageRenderer extends Render
       writer.endElement(HtmlElements.DIV);
     } else {
       writer.endElement(HtmlElements.BODY);
+      writer.endElement(HtmlElements.HTML);
     }
 
     AccessKeyLogger.logStatus(facesContext);

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/HtmlResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/HtmlResponseWriter.java?rev=1772152&r1=1772151&r2=1772152&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/HtmlResponseWriter.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/HtmlResponseWriter.java
Thu Dec  1 08:29:10 2016
@@ -27,12 +27,10 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 
-import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
 import java.io.Writer;
 import java.util.Arrays;
-import java.util.Locale;
 
 public class HtmlResponseWriter extends TobagoResponseWriterBase {
 
@@ -146,14 +144,6 @@ public class HtmlResponseWriter extends
   public void startDocument() throws IOException {
     getWriter().write(HTML_DOCTYPE);
     getWriter().write('\n');
-    startElement(HtmlElements.HTML);
-    final Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
-    if (locale != null) {
-      final String language = locale.getLanguage();
-      if (language != null) {
-        writeAttribute(HtmlAttributes.LANG, language, false);
-      }
-    }
   }
 
   @Override
@@ -172,7 +162,5 @@ public class HtmlResponseWriter extends
 
   @Override
   public void endDocument() throws IOException {
-
-    endElement(HtmlElements.HTML);
   }
 }

Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java?rev=1772152&r1=1772151&r2=1772152&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
Thu Dec  1 08:29:10 2016
@@ -47,8 +47,7 @@ public class TobagoResponseWriterUnitTes
   public void testDocument() throws IOException {
     writer.startDocument();
     writer.endDocument();
-    Assert.assertEquals("content expected",
-        "<!DOCTYPE html>\n\n<html lang='en'>\n</html>", stringWriter.toString());
+    Assert.assertEquals("content expected","<!DOCTYPE html>\n", stringWriter.toString());
   }
 
   @Test



Mime
View raw message