[EMAIL PROTECTED] writes:
Thanks. I still would have preferred to get this quite largeish patch not
one day before the 2.3 release. We're in bugfix/docfix mode.
While I like it, I will back it out for the 2.3 release and put it
back in right after I tagged the tree. Sorry.
Regards
Henning
>seade 2003/09/02 06:28:28
> Modified: src/java/org/apache/turbine TurbineConstants.java
> conf TurbineResources.properties
> src/java/org/apache/turbine/util/template
> HtmlPageAttributes.java
> conf/master TurbineResources.master
> xdocs/howto velocityonlylayout-howto.xml
> src/java/org/apache/turbine/modules/pages DefaultPage.java
> Log:
> Provides an implementation of HtmlPageAttributes.getDefaultDoctype() free from
> specific domain knowledge.
>
> Revision Changes Path
> 1.25 +13 -1
> jakarta-turbine-2/src/java/org/apache/turbine/TurbineConstants.java
>
> Index: TurbineConstants.java
> ===================================================================
> RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/TurbineConstants.java,v
> retrieving revision 1.24
> retrieving revision 1.25
> diff -u -r1.24 -r1.25
> --- TurbineConstants.java 10 Jul 2003 12:33:24 -0000 1.24
> +++ TurbineConstants.java 2 Sep 2003 13:28:28 -0000 1.25
> @@ -60,6 +60,7 @@
> *
> * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
> * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
> + * @author <a href="mailto:[EMAIL PROTECTED]">Scott Eade</a>
> * @version $Id$
> */
> public interface TurbineConstants
> @@ -256,6 +257,17 @@
> String DOCUMENT_TYPE_HTML40STRICT = "Html40Strict";
> /** Html 4.0 Frameset */
> String DOCUMENT_TYPE_HTML40FRAMESET = "Html40Frameset";
> +
> + /** Default doctype root element. */
> + String DEFAULT_HTML_DOCTYPE_ROOT_ELEMENT_KEY
> + = "default.html.doctype.root.element";
> +
> + /** Default doctype dtd. */
> + String DEFAULT_HTML_DOCTYPE_IDENTIFIER_KEY
> + = "default.html.doctype.identifier";
> +
> + /** Default doctype url. */
> + String DEFAULT_HTML_DOCTYPE_URI_KEY = "default.html.doctype.url";
>
> /** Default Language property */
> String LOCALE_DEFAULT_LANGUAGE_KEY = "locale.default.language";
>
>
>
> 1.51 +15 -6 jakarta-turbine-2/conf/TurbineResources.properties
>
> Index: TurbineResources.properties
> ===================================================================
> RCS file: /home/cvs/jakarta-turbine-2/conf/TurbineResources.properties,v
> retrieving revision 1.50
> retrieving revision 1.51
> diff -u -r1.50 -r1.51
> --- TurbineResources.properties 31 Jul 2003 16:32:11 -0000 1.50
> +++ TurbineResources.properties 2 Sep 2003 13:28:28 -0000 1.51
> @@ -161,14 +161,23 @@
>
> screen.invalidstate=error.InvalidState
>
> -# Set the default Doctype. The default Doctype can be set by using
> -# the single strings: Html40Strict, Html40Transitional, or
> -# Html40Frameset. Additionally the default can be supplied as two
> -# strings separated by a comma giving the DTD and URI.
> +# Set the default Doctype if you use the deprecated VelocityECSLayout. The
> +# default Doctype can be set by using the single strings: Html40Strict,
> +# Html40Transitional, or Html40Frameset. Additionally the default can be
> +# supplied as two strings separated by a comma giving the DTD and URI.
> #
> # Default: ignored if not set to some value.
>
> -default.doctype=Html40Transitional
> +#default.doctype=Html40Transitional
> +
> +# Set the components of the default Doctype for use in html documents.
> +#
> +# Defaults: There are no defaults - if default.html.doctype.root.element is not
> +# set then no default doctype will be available.
> +
> +default.html.doctype.root.element=HTML
> +default.html.doctype.identifier=-//W3C//DTD HTML 4.01 Transitional//EN
> +default.html.doctype.url=http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd
>
> # This is the default action to log a user in. If you write your own
> # implementation of the login action, make sure that you change this
>
>
>
> 1.10 +19 -89
> jakarta-turbine-2/src/java/org/apache/turbine/util/template/HtmlPageAttributes.java
>
> Index: HtmlPageAttributes.java
> ===================================================================
> RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/template/HtmlPageAttributes.java,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -u -r1.9 -r1.10
> --- HtmlPageAttributes.java 2 Sep 2003 06:25:48 -0000 1.9
> +++ HtmlPageAttributes.java 2 Sep 2003 13:28:28 -0000 1.10
> @@ -58,7 +58,6 @@
> import java.util.List;
> import java.util.Map;
> import java.util.ArrayList;
> -import java.util.Vector;
>
> import org.apache.commons.lang.StringUtils;
> import org.apache.commons.logging.Log;
> @@ -67,7 +66,6 @@
> import org.apache.turbine.TurbineConstants;
> import org.apache.turbine.services.pull.ApplicationTool;
> import org.apache.turbine.util.RunData;
> -import org.apache.turbine.util.TurbineException;
>
> /**
> * Template context tool that can be used to set various attributes of a
> @@ -128,6 +126,7 @@
> * $page.setHttpEquiv("refresh","5; URL=http://localhost/nextpage.html")</code>
> *
> * @author <a href="mailto:[EMAIL PROTECTED]">Quinton McCombs</a>
> + * @author <a href="mailto:[EMAIL PROTECTED]">Scott Eade</a>
> * @version $Id$
> */
> public class HtmlPageAttributes
> @@ -661,104 +660,35 @@
> }
>
> /**
> - * Retrieve the default Doctype. If Doctype is set to null, then an empty
> - * string will be returned. The default Doctype can be set in
> - * TurbineResources as three strings giving the tag (e.g. "HTML"), dtd (e.g.
> - * "-//W3C//DTD HTML 4.01 Transitional//EN") and uri (e.g.
> - * "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"). For
> - * backwards compatibility the default can be set using one of the single
> - * strings: Html40Strict, Html40Transitional, or Html40Frameset or as two
> - * strings providing the the dtd and uri (tag is assumed to be "HTML") -
> - * all but the three string configuration will result in an info level
> - * deprecation message being written to the log.
> - *
> - * @exception TurbineException If the default doctype is not specified in
> + * Retrieve the default Doctype as configured by the
> + * TurbineResources.peoperties
> + * default.doctype.root.element, default.doctype.identifier and
> + * default.doctype.url properties (defaults are "HTML",
> + * "-//W3C//DTD HTML 4.01 Transitional//EN" and
> + * "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd" respectively).
> + *
> + * @return the DOCTYPE tag constructed from the properties in
> * TurbineResources.properties.
> */
> public static String getDefaultDoctype()
> - throws TurbineException
> {
> if (doctype == null)
> {
> - String errMsg = "default.doctype property not set properly in "
> - + "TurbineResources.properties!";
> - Vector doctypeProperty = Turbine.getConfiguration()
> - .getVector(TurbineConstants.DEFAULT_DOCUMENT_TYPE_KEY);
> -
> - if (doctypeProperty != null)
> + String tag = Turbine.getConfiguration().getString(
> + TurbineConstants.DEFAULT_HTML_DOCTYPE_ROOT_ELEMENT_KEY);
> + if (StringUtils.isEmpty(tag))
> {
> - String tag;
> - String identifier;
> - String uri;
> - switch(doctypeProperty.size())
> - {
> - case 1:
> - {
> - String doc = (String) doctypeProperty.firstElement();
> - tag = "HTML";
> - identifier = "-//W3C//DTD HTML 4.0 ";
> - uri = "http://www.w3.org/TR/REC-html40/";
> - if (doc.equalsIgnoreCase(
> - TurbineConstants.DOCUMENT_TYPE_HTML40TRANSITIONAL))
> - {
> - identifier += "Transitional";
uri += "loose";
> - }
> - else if (doc.equalsIgnoreCase(
> - TurbineConstants.DOCUMENT_TYPE_HTML40STRICT))
> - {
> - uri += "strict";
> - }
> - else if (doc.equalsIgnoreCase(
> - TurbineConstants.DOCUMENT_TYPE_HTML40FRAMESET))
> - {
> - identifier = "Frameset";
> - uri += "frameset";
> - }
> - else
> - {
> - throw new TurbineException(errMsg);
> - }
> - identifier += "//EN";
> - uri += ".dtd";
> -
> - log.info("Defining default.doctype with a single string"
> - + " in TurbineResources.properties is deprecated. "
> - + "Please use three strings instead (tag, dtd and "
> - + "uri).");
> - break;
> - }
> - case 2:
> - {
> - tag = "HTML";
> - identifier = (String) doctypeProperty.elementAt(0);
> - uri = (String) doctypeProperty.elementAt(1);
> -
> - log.info("Defining default.doctype with two strings"
> - + " in TurbineResources.properties is deprecated. "
> - + "Please use three strings instead (tag, dtd and "
> - + "uri).");
> - break;
> - }
> - case 3:
> - {
> - tag = (String) doctypeProperty.elementAt(0);
> - identifier = (String) doctypeProperty.elementAt(1);
> - uri = (String) doctypeProperty.elementAt(2);
> - break;
> - }
> - default:
> - {
> - throw new TurbineException(errMsg);
> - }
> - }
> - doctype = getDoctype(tag, identifier, uri);
> + doctype = "";
> }
> else
> {
> - doctype = "";
> + String identifier = Turbine.getConfiguration().getString(
> + TurbineConstants.DEFAULT_HTML_DOCTYPE_IDENTIFIER_KEY);
> + String uri = Turbine.getConfiguration().getString(
> + TurbineConstants.DEFAULT_HTML_DOCTYPE_URI_KEY);
> + doctype = getDoctype(tag, identifier, uri);
> }
> }
> -
> return doctype;
> }
>
>
>
>
> 1.50 +15 -6 jakarta-turbine-2/conf/master/TurbineResources.master
>
> Index: TurbineResources.master
> ===================================================================
> RCS file: /home/cvs/jakarta-turbine-2/conf/master/TurbineResources.master,v
> retrieving revision 1.49
> retrieving revision 1.50
> diff -u -r1.49 -r1.50
> --- TurbineResources.master 31 Jul 2003 16:32:11 -0000 1.49
> +++ TurbineResources.master 2 Sep 2003 13:28:28 -0000 1.50
> @@ -161,14 +161,23 @@
>
> [EMAIL PROTECTED]@
>
> -# Set the default Doctype. The default Doctype can be set by using
> -# the single strings: Html40Strict, Html40Transitional, or
> -# Html40Frameset. Additionally the default can be supplied as two
> -# strings separated by a comma giving the DTD and URI.
> +# Set the default Doctype if you use the deprecated VelocityECSLayout. The
> +# default Doctype can be set by using the single strings: Html40Strict,
> +# Html40Transitional, or Html40Frameset. Additionally the default can be
> +# supplied as two strings separated by a comma giving the DTD and URI.
> #
> # Default: ignored if not set to some value.
>
> -default.doctype=Html40Transitional
> +#default.doctype=Html40Transitional
> +
> +# Set the components of the default Doctype for use in html documents.
> +#
> +# Defaults: There are no defaults - if default.html.doctype.root.element is not
> +# set then no default doctype will be available.
> +
> +default.html.doctype.root.element=HTML
> +default.html.doctype.identifier=-//W3C//DTD HTML 4.01 Transitional//EN
> +default.html.doctype.url=http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd
>
> # This is the default action to log a user in. If you write your own
> # implementation of the login action, make sure that you change this
>
>
>
> 1.5 +14 -2 jakarta-turbine-2/xdocs/howto/velocityonlylayout-howto.xml
>
> Index: velocityonlylayout-howto.xml
> ===================================================================
> RCS file: /home/cvs/jakarta-turbine-2/xdocs/howto/velocityonlylayout-howto.xml,v
> retrieving revision 1.4
> retrieving revision 1.5
> diff -u -r1.4 -r1.5
> --- velocityonlylayout-howto.xml 2 Sep 2003 07:22:10 -0000 1.4
> +++ velocityonlylayout-howto.xml 2 Sep 2003 13:28:28 -0000 1.5
> @@ -79,9 +79,21 @@
> ]]>
> </source>
> <p>
> - to your templates to pick up the default doctype definition from
> - TurbineResources.properties and make it available as $page.DefaultDoctype.
> + to your layout templates to pick up the default doctype definition from
> + TurbineResources.properties thus:
> </p>
> +<source>
> +<![CDATA[
> +# Set the components of the default Doctype for use in html documents.
> +#
> +# Defaults: There are no defaults - if default.html.doctype.root.element is not
> +# set then no default doctype will be available.
> +
> +default.html.doctype.root.element=HTML
> +default.html.doctype.identifier=-//W3C//DTD HTML 4.01 Transitional//EN
> +default.html.doctype.url=http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd
> +]]>
> +</source>
> <p>
> Add the line
> </p>
>
>
>
> 1.9 +6 -10
> jakarta-turbine-2/src/java/org/apache/turbine/modules/pages/DefaultPage.java
>
> Index: DefaultPage.java
> ===================================================================
> RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/pages/DefaultPage.java,v
> retrieving revision 1.8
> retrieving revision 1.9
> diff -u -r1.8 -r1.9
> --- DefaultPage.java 2 Sep 2003 06:25:49 -0000 1.8
> +++ DefaultPage.java 2 Sep 2003 13:28:28 -0000 1.9
> @@ -255,6 +255,11 @@
> {
> switch(doctypeProperty.size())
> {
> + case 0:
> + {
> + // Don't add a doctype.
> + break;
> + }
> case 1:
> {
> String doc = (String) doctypeProperty.firstElement();
> @@ -282,15 +287,6 @@
> .setDoctype(new Doctype()
> .setIdentifier((String)
> doctypeProperty.elementAt(0))
> .setUri((String)
> doctypeProperty.elementAt(1)));
> - break;
> - }
> - case 3:
> - {
> - // Ignore first string as the tag value is provided by ECS.
> - data.getPage()
> - .setDoctype(new Doctype()
> - .setIdentifier((String)
> doctypeProperty.elementAt(1))
> - .setUri((String)
> doctypeProperty.elementAt(2)));
> break;
> }
> default:
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
[EMAIL PROTECTED] +49 9131 50 654 0 http://www.intermeta.de/
Java, perl, Solaris, Linux, xSP Consulting, Web Services
freelance consultant -- Jakarta Turbine Development -- hero for hire
"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
-- AOL CD when played backwards (User Friendly - 200-10-15)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]