You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by aw...@apache.org on 2007/09/12 00:58:20 UTC

svn commit: r574721 - in /myfaces/trinidad/trunk/trinidad: src/site/xdoc/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/inc...

Author: awiner
Date: Tue Sep 11 15:58:19 2007
New Revision: 574721

URL: http://svn.apache.org/viewvc?rev=574721&view=rev
Log:
TRINIDAD-658: Add doctype flag to trh:html and trh:document to allow switching doctype to quirks mode
- Added "mode" flag to trh:html and tr:document that can be used to force quirks or strict

Added:
    myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonDocumentAttrs.xml
Modified:
    myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml
    myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreDocument.xml
    myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/html/HtmlHtml.xml
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HtmlRenderer.java

Modified: myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml?rev=574721&r1=574720&r2=574721&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml (original)
+++ myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml Tue Sep 11 15:58:19 2007
@@ -47,7 +47,13 @@
       <section name="Release Notes">
 <subsection name="Features">
 
-<ul>Added tr:panelCaptionGroup component to render HTML fieldset/legend content groups.
+<ul>
+<li>Added tr:panelCaptionGroup component to render HTML fieldset/legend content groups.</li>
+<li>A new addDomReplaceListener() method on the page Javascript
+object lets a developer receive notification when DOM is
+replaced by PPR.</li>
+<li>A new "mode" attribute on tr:document and trh:html lets you force Trinidad to enable "quirks" mode or to a "strict" DTD.  By default, Trinidad still renders with a transitional DTD but with standards-mode rendering.  Note: "strict" mode does not currently change how Trinidad renders - it simply swaps the DTD.</li>
+<li>The "toolbar" facet is now supported on showDetailItems in panelAccordion.</li>
 </ul>
 
 </subsection>
@@ -81,10 +87,6 @@
     
 <subsection name="New Features">
 <ul>
-<li>A new addDomReplaceListener() method on the page Javascript
-object lets a developer receive notification when DOM is
-replaced by PPR.</li>
-<li>The "toolbar" facet is now supported on showDetailItems in panelAccordion.</li>
 </ul>
 </subsection>
 

Modified: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreDocument.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreDocument.xml?rev=574721&r1=574720&r2=574721&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreDocument.xml (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreDocument.xml Tue Sep 11 15:58:19 2007
@@ -50,6 +50,7 @@
       </property-extension>
     </property>
 
+    <xi:include href="includes/CommonDocumentAttrs.xml" xpointer="/faces-config/component/*"/>
     <xi:include href="includes/CommonAttrs.xml" xpointer="/faces-config/component/*"/>
     <xi:include href="includes/CoreJSEvents.xml" xpointer="/faces-config/component/*"/>
 

Added: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonDocumentAttrs.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonDocumentAttrs.xml?rev=574721&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonDocumentAttrs.xml (added)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonDocumentAttrs.xml Tue Sep 11 15:58:19 2007
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    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.
+	   
+--><faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin">
+  <component>
+    <property>
+      <description>
+        <![CDATA[Set if the page should render in default standards mode, quirks mode, or strict mode.  Behavior of the modes are:<ul>
+<li>"default": renders as transitional doctypes for both XHTML and HTML,
+with <a href="http://developer.mozilla.org/en/docs/Gecko's_%22Almost_Standards%22_Mode">"almost standards"</a> rendering mode</li>
+<li>"strict": renders as a strict doctype for both XHTML and HTML, also
+in standards rendering mode</li>
+<li>"quirks": renders HTML pages in quirks mode, and XHTML with
+a transitional doctype, but standards mode  (there is no quirks mode for
+XHTML). ]]>
+      </description>
+      <property-name>mode</property-name>
+      <property-class>java.lang.String</property-class>
+      <default-value>default</default-value>
+      <property-extension>
+        <mfp:property-values>default strict quirks</mfp:property-values>
+      </property-extension>
+    </property>
+  </component>
+</faces-config>

Modified: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/html/HtmlHtml.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/html/HtmlHtml.xml?rev=574721&r1=574720&r2=574721&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/html/HtmlHtml.xml (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/html/HtmlHtml.xml Tue Sep 11 15:58:19 2007
@@ -19,6 +19,7 @@
 	   
 -->
 <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xi="http://www.w3.org/2001/XInclude"
               xmlns:trh="http://myfaces.apache.org/trinidad/html"
               xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin"
               xmlns:xhtml="http://www.w3.org/1999/xhtml">
@@ -28,6 +29,8 @@
     <icon>
       <small-icon>/org/apache/myfaces/trinidad/metadata/icons/html.png</small-icon>
     </icon>
+    <xi:include href="../core/includes/CommonDocumentAttrs.xml" xpointer="/faces-config/component/*"/>
+
     <component-type>org.apache.myfaces.trinidad.HtmlHtml</component-type>
     <component-class>org.apache.myfaces.trinidad.component.html.HtmlHtml</component-class>
     <component-extension>

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HtmlRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HtmlRenderer.java?rev=574721&r1=574720&r2=574721&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HtmlRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HtmlRenderer.java Tue Sep 11 15:58:19 2007
@@ -27,6 +27,7 @@
 import javax.faces.context.ResponseWriter;
 
 import org.apache.myfaces.trinidad.bean.FacesBean;
+import org.apache.myfaces.trinidad.bean.PropertyKey;
 import org.apache.myfaces.trinidad.component.html.HtmlFrameBorderLayout;
 import org.apache.myfaces.trinidad.component.html.HtmlHtml;
 
@@ -63,6 +64,13 @@
   }
 
   @Override
+  protected void findTypeConstants(FacesBean.Type type)
+  {
+    super.findTypeConstants(type);
+    _modeKey = type.findKey("mode");
+  }
+
+  @Override
   protected void encodeBegin(
     FacesContext        context,
     RenderingContext arc,
@@ -71,7 +79,7 @@
   {
     ResponseWriter writer = context.getResponseWriter();
 
-    String docType = getDocType(context, comp);
+    String docType = getDocType(context, comp, bean);
     if (docType != null)
       writer.write(docType);
 
@@ -117,12 +125,18 @@
     rw.endElement("html");
   }
 
+  protected String getMode(FacesBean bean)
+  {
+    return toString(bean.getProperty(_modeKey));
+  }
+
   /**
    * Subclasses should override to return their doctype
    */
   protected String getDocType(
     FacesContext context,
-    UIComponent  component)
+    UIComponent  component,
+    FacesBean    bean)
   {
     // See bug 1893192 - we don't want to render the DTD
     // in Mozilla until we can fix our code to work in their
@@ -138,7 +152,7 @@
     }
     else
     {
-      return getDocumentDocType(context);
+      return getDocumentDocType(context, bean);
     }
   }
 
@@ -167,20 +181,27 @@
    * to a frameset.
    */
   protected String getDocumentDocType(
-    FacesContext context
+    FacesContext context,
+    FacesBean    bean
     )
   {
+    String mode = getMode(bean);
     // default to transitional, rather than strict
     if (isXMLDocument(context))
     {
-      return XHTML_TRANSITIONAL_DOCTYPE;
+      if (HtmlHtml.MODE_STRICT.equals(mode))
+        return XHTML_STRICT_DOCTYPE;
+      else
+        return XHTML_TRANSITIONAL_DOCTYPE;
     }
     else
     {
-      if (isStandardsModeDisabled(context))
-        return HTML_TRANSITIONAL_DOCTYPE;
-      else
+      if (isStandardsModeDisabled(context) || HtmlHtml.MODE_QUIRKS.equals(mode))
+        return HTML_QUIRKS_DOCTYPE;
+      else if (HtmlHtml.MODE_STRICT.equals(mode))
         return HTML_STRICT_DOCTYPE;
+      else
+        return HTML_STANDARDS_DOCTYPE;
     }
   }
 
@@ -228,17 +249,19 @@
            "application/xml".equals(contentType);
   }
 
+  private PropertyKey _modeKey;
 
-  protected static final String HTML_TRANSITIONAL_DOCTYPE =
+  // DOCTYPE for transitional + quirks
+  protected static final String HTML_QUIRKS_DOCTYPE =
     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
-  /**
-   * Note that the following docType does not work in IE6. see bug 2342217
-   *
+
+  // DOCTYPE for transitional + standards
+  protected static final String HTML_STANDARDS_DOCTYPE =
     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
-  **/
 
+  // DOCTYPE for strict + standards
   protected static final String HTML_STRICT_DOCTYPE =
-    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
+    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
 
   // loose plus FRAMESET instead of BODY
   protected static final String HTML_FRAMESET_DOCTYPE =