You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2010/03/23 07:32:37 UTC

svn commit: r926475 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/config/ core/src/main/java/org/apache/myfaces/tobago/renderkit/ core/src/main/java/org/apache/myfaces/tobago/webapp/ core/src/test/java/org/apache/myfaces/toba...

Author: bommel
Date: Tue Mar 23 06:32:37 2010
New Revision: 926475

URL: http://svn.apache.org/viewvc?rev=926475&view=rev
Log:
(TOBAGO-863) Split TobagoResponseWriterImpl into a XmlResponseWriter and a normal HtmlResponseWriter and introduce a Debug Response Writer

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java
    myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/taglib/component/GenericComponentTagUnitTest.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/config/TobagoConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java?rev=926475&r1=926474&r2=926475&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java Tue Mar 23 06:32:37 2010
@@ -60,7 +60,7 @@ public class TobagoConfig {
   public void addSupportedThemeName(String name) {
     supportedThemeNames.add(name);
   }
-
+  // TODO one init method
   public void resolveThemes() {
     if (defaultThemeName != null) {
       defaultTheme = availableTheme.get(defaultThemeName);
@@ -181,6 +181,10 @@ public class TobagoConfig {
     this.renderersConfig = renderersConfig;
   }
 
+  public ProjectStage getProjectStage() {
+    return projectStage;
+  }
+  // TODO one init method
   public void initProjectState(ServletContext servletContext) {
     String stageName = null;
     try {
@@ -217,7 +221,7 @@ public class TobagoConfig {
       if (LOG.isInfoEnabled()) {
         LOG.info("Couldn't discover the current project stage, using " + ProjectStage.Production);
       }
-      projectStage = ProjectStage.Production;
+      projectStage = ProjectStage.Development;
     }
   }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java?rev=926475&r1=926474&r2=926475&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/TobagoRenderKit.java Tue Mar 23 06:32:37 2010
@@ -19,6 +19,9 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.application.ProjectStage;
+import org.apache.myfaces.tobago.config.TobagoConfig;
+import org.apache.myfaces.tobago.internal.webapp.DebugTobagoResponseWriterWrapper;
 import org.apache.myfaces.tobago.internal.webapp.TobagoResponseJsonWriterImpl;
 import org.apache.myfaces.tobago.internal.webapp.TobagoResponseWriterImpl;
 import org.apache.myfaces.tobago.internal.webapp.TobagoResponseXmlWriterImpl;
@@ -114,10 +117,9 @@ public class TobagoRenderKit extends Ren
     } else {
       responseWriter = new TobagoResponseWriterImpl(writer, contentType, characterEncoding);
     }
-    /* TODO if ProjectState Development use the Debug Response Writer
-    if (ProjectStage.Development)) {
+    if (TobagoConfig.getInstance(FacesContext.getCurrentInstance()).getProjectStage().equals(ProjectStage.Development)) {
       return new DebugTobagoResponseWriterWrapper(responseWriter);
-    } */
+    }
     return responseWriter;
   }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java?rev=926475&r1=926474&r2=926475&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java Tue Mar 23 06:32:37 2010
@@ -58,11 +58,10 @@ public class TobagoServletContextListene
 
       // prepare themes
       tobagoConfig.resolveThemes();
-
+      tobagoConfig.initProjectState(servletContext);
     } catch (Throwable e) {
       if (LOG.isFatalEnabled()) {
-        String error = "Error while deploy process. Tobago can't be initialized! "
-            + "Application will not run!";
+        String error = "Error while deploy process. Tobago can't be initialized! Application will not run!";
         LOG.fatal(error, e);
         throw new RuntimeException(error, e);
       }

Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/taglib/component/GenericComponentTagUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/taglib/component/GenericComponentTagUnitTest.java?rev=926475&r1=926474&r2=926475&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/taglib/component/GenericComponentTagUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/taglib/component/GenericComponentTagUnitTest.java Tue Mar 23 06:32:37 2010
@@ -81,6 +81,7 @@ public class GenericComponentTagUnitTest
     availableThemes.put(theme1.getName(), theme1);
     tobagoConfig.setAvailableThemes(availableThemes);
     tobagoConfig.resolveThemes();
+    tobagoConfig.initProjectState(servletContext);
     servletContext.setAttribute(TobagoConfig.TOBAGO_CONFIG, tobagoConfig);
     HttpServletRequest request = new MockHttpServletRequest();
     HttpServletResponse response = new MockHttpServletResponse();

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?rev=926475&r1=926474&r2=926475&view=diff
==============================================================================
--- 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 Tue Mar 23 06:32:37 2010
@@ -20,7 +20,12 @@ package org.apache.myfaces.tobago.render
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.tobago.component.*;
+import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.component.UIForm;
+import org.apache.myfaces.tobago.component.UIMenuBar;
+import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.component.UIPopup;
 import org.apache.myfaces.tobago.config.Configurable;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
@@ -52,21 +57,17 @@ import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
 import java.text.DecimalFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 public class PageRenderer extends PageRendererBase {
 
   private static final Log LOG = LogFactory.getLog(PageRenderer.class);
 
-  private static final String XHTML_DOCTYPE =
-      "<!DOCTYPE html "
-          + "     PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
-          + "     \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
-
-  private static final String HTML_DOCTYPE =
-      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""
-          + " \"http://www.w3.org/TR/html4/strict.dtd\">";
-
   private static final String CLIENT_DEBUG_SEVERITY = "clientDebugSeverity";
   private static final String LAST_FOCUS_ID = "lastFocusId";
 
@@ -136,17 +137,6 @@ public class PageRenderer extends PageRe
 
     String title = (String) page.getAttributes().get(Attributes.LABEL);
 
-    if (writer.isXml()) {
-      writer.write(XHTML_DOCTYPE);
-    } else {
-      writer.write(HTML_DOCTYPE);
-    }
-    writer.write('\n');
-
-    writer.startElement(HtmlConstants.HTML, null);
-    if (writer.isXml()) {
-      writer.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml", false);
-    }
     writer.startElement(HtmlConstants.HEAD, null);
     final boolean debugMode = VariableResolverUtils.resolveClientProperties(facesContext).isDebugMode();
 
@@ -535,7 +525,6 @@ public class PageRenderer extends PageRe
     writer.writeJavascript("setTimeout(\"Tobago.init('" + clientId + "')\", 1000)");
 
     writer.endElement(HtmlConstants.BODY);
-    writer.endElement(HtmlConstants.HTML);
 
     if (LOG.isDebugEnabled()) {
       LOG.debug("unused AccessKeys    : "