You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2007/07/11 17:57:08 UTC
svn commit: r555316 - in /tiles/framework/trunk:
tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/
tiles-compat/src/main/java/org/apache/tiles/config/
tiles-compat/src/test/java/org/ tiles-compat/src/test/java/org/apache/
tiles-co...
Author: apetrelli
Date: Wed Jul 11 08:57:06 2007
New Revision: 555316
URL: http://svn.apache.org/viewvc?view=rev&rev=555316
Log:
TILES-156
Coding finished to allow reading old-format Tiles definition files, now it needs some testing.
Added:
tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/package.html (with props)
tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/
tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-1.1.xml
tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-2.0.xml
tiles/framework/trunk/tiles-compat/src/test/java/org/
tiles/framework/trunk/tiles-compat/src/test/java/org/apache/
tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/
tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/
tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/
tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/
tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/TestCompatibilityDigesterDefinitionsReader.java (with props)
Modified:
tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/CompatibilityDigesterDefinitionsReader.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java
Modified: tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/CompatibilityDigesterDefinitionsReader.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/CompatibilityDigesterDefinitionsReader.java?view=diff&rev=555316&r1=555315&r2=555316
==============================================================================
--- tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/CompatibilityDigesterDefinitionsReader.java (original)
+++ tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/CompatibilityDigesterDefinitionsReader.java Wed Jul 11 08:57:06 2007
@@ -1,9 +1,34 @@
+/*
+ * $Id$
+ *
+ * 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.tiles.compat.definition.digester;
import org.apache.commons.digester.Digester;
import org.apache.tiles.definition.digester.DigesterDefinitionsReader;
-import org.apache.tiles.definition.digester.DigesterDefinitionsReader.FillAttributeRule;
+/**
+ * Digester reader that can read Tiles 1.1, 1.2, 1.3, 1.4 and 2.0 files.
+ *
+ * @version $Rev$ $Date$
+ */
public class CompatibilityDigesterDefinitionsReader extends
DigesterDefinitionsReader {
/**
@@ -11,7 +36,7 @@
* versions of the configuration file DTDs we know about. There <strong>MUST</strong>
* be an even number of Strings in this list!
*/
- protected String registrations[] = {
+ protected String[] registrations = {
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN",
"/org/apache/tiles/resources/tiles-config_2_0.dtd",
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN",
@@ -21,176 +46,151 @@
"-//Apache Software Foundation//DTD Tiles Configuration 1.4//EN",
"/org/apache/tiles/compat/resources/tiles-config_1_4.dtd" };
+ /** {@inheritDoc} */
@Override
protected void initSyntax(Digester digester) {
super.initSyntax(digester);
initDigesterForComponentsDefinitionsSyntax(digester);
+ initDigesterForInstancesSyntax(digester);
+ initDigesterForTilesDefinitionsSyntax(digester);
}
/**
* Init digester for components syntax. This is an old set of rules, left
* for backward compatibility.
- *
+ *
* @param digester Digester instance to use.
*/
private void initDigesterForComponentsDefinitionsSyntax(Digester digester) {
// Common constants
- String DEFINITION_TAG = "component-definitions/definition";
+ String definitionTag = "component-definitions/definition";
- String PUT_TAG = DEFINITION_TAG + "/put";
+ String putTag = definitionTag + "/put";
- String LIST_TAG = DEFINITION_TAG + "/putList";
+ String listTag = definitionTag + "/putList";
- String ADD_LIST_ELE_TAG = LIST_TAG + "/add";
+ String addListElementTag = listTag + "/add";
// syntax rules
- digester.addObjectCreate(DEFINITION_TAG, DEFINITION_HANDLER_CLASS);
- digester.addSetProperties(DEFINITION_TAG);
- digester.addSetNext(DEFINITION_TAG, "putDefinition",
+ digester.addObjectCreate(definitionTag, DEFINITION_HANDLER_CLASS);
+ digester.addSetProperties(definitionTag);
+ digester.addSetNext(definitionTag, "addDefinition",
DEFINITION_HANDLER_CLASS);
// put / putAttribute rules
- digester.addObjectCreate(PUT_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addRule(PUT_TAG, new FillAttributeRule());
- digester.addSetNext(PUT_TAG, "addAttribute",
+ digester.addObjectCreate(putTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addRule(putTag, new FillAttributeRule());
+ digester.addSetNext(putTag, "addAttribute",
PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addCallMethod(PUT_TAG, "setBody", 0);
+ digester.addCallMethod(putTag, "setBody", 0);
// list rules
- digester.addObjectCreate(LIST_TAG, LIST_HANDLER_CLASS);
- digester.addSetProperties(LIST_TAG);
- digester.addSetNext(LIST_TAG, "addAttribute",
+ digester.addObjectCreate(listTag, LIST_HANDLER_CLASS);
+ digester.addSetProperties(listTag);
+ digester.addSetNext(listTag, "addAttribute",
PUT_ATTRIBUTE_HANDLER_CLASS);
// list elements rules
// We use Attribute class to avoid rewriting a new class.
// Name part can't be used in listElement attribute.
- digester.addObjectCreate(ADD_LIST_ELE_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addRule(ADD_LIST_ELE_TAG, new FillAttributeRule());
- digester.addSetNext(ADD_LIST_ELE_TAG, "add",
+ digester.addObjectCreate(addListElementTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addRule(addListElementTag, new FillAttributeRule());
+ digester.addSetNext(addListElementTag, "add",
PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addCallMethod(ADD_LIST_ELE_TAG, "setBody", 0);
+ digester.addCallMethod(addListElementTag, "setBody", 0);
}
/**
* Init digester for Tiles syntax. Same as components, but with first
* element = tiles-definitions
- *
+ *
* @param digester Digester instance to use.
*/
private void initDigesterForTilesDefinitionsSyntax(Digester digester) {
// Common constants
- String DEFINITION_TAG = "tiles-definitions/definition";
+ String definitionTag = "tiles-definitions/definition";
- String PUT_TAG = DEFINITION_TAG + "/put";
+ String putTag = definitionTag + "/put";
// String LIST_TAG = DEFINITION_TAG + "/putList";
// List tag value
- String LIST_TAG = "putList";
- String DEF_LIST_TAG = DEFINITION_TAG + "/" + LIST_TAG;
+ String listTag = "putList";
+ String definitionListTag = definitionTag + "/" + listTag;
// Tag value for adding an element in a list
- String ADD_LIST_ELE_TAG = "*/" + LIST_TAG + "/add";
+ String addListElementTag = "*/" + listTag + "/add";
- // syntax rules
- digester.addObjectCreate(DEFINITION_TAG, DEFINITION_HANDLER_CLASS);
- digester.addSetProperties(DEFINITION_TAG);
- digester.addSetNext(DEFINITION_TAG, "putDefinition",
- DEFINITION_HANDLER_CLASS);
// put / putAttribute rules
// Rules for a same pattern are called in order, but rule.end() are
// called
// in reverse order.
// SetNext and CallMethod use rule.end() method. So, placing SetNext in
// first position ensure it will be called last (sic).
- digester.addObjectCreate(PUT_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addRule(PUT_TAG, new FillAttributeRule());
- digester.addSetNext(PUT_TAG, "addAttribute",
+ digester.addObjectCreate(putTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addRule(putTag, new FillAttributeRule());
+ digester.addSetNext(putTag, "addAttribute",
PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addCallMethod(PUT_TAG, "setBody", 0);
+ digester.addCallMethod(putTag, "setBody", 0);
// Definition level list rules
// This is rules for lists nested in a definition
- digester.addObjectCreate(DEF_LIST_TAG, LIST_HANDLER_CLASS);
- digester.addSetProperties(DEF_LIST_TAG);
- digester.addSetNext(DEF_LIST_TAG, "addAttribute",
+ digester.addObjectCreate(definitionListTag, LIST_HANDLER_CLASS);
+ digester.addSetProperties(definitionListTag);
+ digester.addSetNext(definitionListTag, "addAttribute",
PUT_ATTRIBUTE_HANDLER_CLASS);
// list elements rules
// We use Attribute class to avoid rewriting a new class.
// Name part can't be used in listElement attribute.
- digester.addObjectCreate(ADD_LIST_ELE_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addRule(ADD_LIST_ELE_TAG, new FillAttributeRule());
- digester.addSetNext(ADD_LIST_ELE_TAG, "add",
+ digester.addObjectCreate(addListElementTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addRule(addListElementTag, new FillAttributeRule());
+ digester.addSetNext(addListElementTag, "add",
PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addCallMethod(ADD_LIST_ELE_TAG, "setBody", 0);
+ digester.addCallMethod(addListElementTag, "setBody", 0);
// nested list elements rules
// Create a list handler, and add it to parent list
- String NESTED_LIST = "*/" + LIST_TAG + "/" + LIST_TAG;
- digester.addObjectCreate(NESTED_LIST, LIST_HANDLER_CLASS);
- digester.addSetProperties(NESTED_LIST);
- digester.addSetNext(NESTED_LIST, "add", PUT_ATTRIBUTE_HANDLER_CLASS);
-
- // item elements rules
- // We use Attribute class to avoid rewriting a new class.
- // Name part can't be used in listElement attribute.
- // String ADD_WILDCARD = LIST_TAG + "/addItem";
- // non String ADD_WILDCARD = LIST_TAG + "/addx*";
- String ADD_WILDCARD = "*/item";
- String menuItemDefaultClass = "org.apache.struts.tiles.beans.SimpleMenuItem";
- digester.addObjectCreate(ADD_WILDCARD, menuItemDefaultClass,
- "classtype");
- digester.addSetNext(ADD_WILDCARD, "add", "java.lang.Object");
- digester.addSetProperties(ADD_WILDCARD);
-
- // bean elements rules
- String BEAN_TAG = "*/bean";
- String beanDefaultClass = "org.apache.struts.tiles.beans.SimpleMenuItem";
- digester.addObjectCreate(BEAN_TAG, beanDefaultClass, "classtype");
- digester.addSetNext(BEAN_TAG, "add", "java.lang.Object");
- digester.addSetProperties(BEAN_TAG);
-
- // Set properties to surrounding element
- digester
- .addSetProperty(BEAN_TAG + "/set-property", "property", "value");
+ String nestedList = "*/" + listTag + "/" + listTag;
+ digester.addObjectCreate(nestedList, LIST_HANDLER_CLASS);
+ digester.addSetProperties(nestedList);
+ digester.addSetNext(nestedList, "add", PUT_ATTRIBUTE_HANDLER_CLASS);
}
/**
* Init digester in order to parse instances definition file syntax.
* Instances is an old name for "definition". This method is left for
* backwards compatibility.
- *
+ *
* @param digester Digester instance to use.
*/
private void initDigesterForInstancesSyntax(Digester digester) {
// Build a digester to process our configuration resource
- String INSTANCE_TAG = "component-instances/instance";
+ String instanceTag = "component-instances/instance";
- String PUT_TAG = INSTANCE_TAG + "/put";
- String PUTATTRIBUTE_TAG = INSTANCE_TAG + "/putAttribute";
+ String putTag = instanceTag + "/put";
+ String putAttributeTag = instanceTag + "/putAttribute";
- String LIST_TAG = INSTANCE_TAG + "/putList";
+ String listTag = instanceTag + "/putList";
- String ADD_LIST_ELE_TAG = LIST_TAG + "/add";
+ String addListElementTag = listTag + "/add";
// component instance rules
- digester.addObjectCreate(INSTANCE_TAG, DEFINITION_HANDLER_CLASS);
- digester.addSetProperties(INSTANCE_TAG);
+ digester.addObjectCreate(instanceTag, DEFINITION_HANDLER_CLASS);
+ digester.addSetProperties(instanceTag);
digester
- .addSetNext(INSTANCE_TAG, "putDefinition", DEFINITION_HANDLER_CLASS);
+ .addSetNext(instanceTag, "addDefinition", DEFINITION_HANDLER_CLASS);
// put / putAttribute rules
- digester.addObjectCreate(PUTATTRIBUTE_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addRule(PUT_TAG, new FillAttributeRule());
- digester.addSetNext(PUTATTRIBUTE_TAG, "addAttribute",
+ digester.addObjectCreate(putAttributeTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addRule(putTag, new FillAttributeRule());
+ digester.addSetNext(putAttributeTag, "addAttribute",
PUT_ATTRIBUTE_HANDLER_CLASS);
// put / putAttribute rules
- digester.addObjectCreate(PUT_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addSetProperties(PUT_TAG);
- digester.addSetNext(PUT_TAG, "addAttribute", PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addObjectCreate(putTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addSetProperties(putTag);
+ digester.addSetNext(putTag, "addAttribute", PUT_ATTRIBUTE_HANDLER_CLASS);
// list rules
- digester.addObjectCreate(LIST_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addSetProperties(LIST_TAG);
- digester.addSetNext(LIST_TAG, "addAttribute", PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addObjectCreate(listTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addSetProperties(listTag);
+ digester.addSetNext(listTag, "addAttribute", PUT_ATTRIBUTE_HANDLER_CLASS);
// list elements rules
// We use Attribute class to avoid rewriting a new class.
// Name part can't be used in listElement attribute.
- digester.addObjectCreate(ADD_LIST_ELE_TAG, PUT_ATTRIBUTE_HANDLER_CLASS);
- digester.addRule(ADD_LIST_ELE_TAG, new FillAttributeRule());
- digester.addSetNext(ADD_LIST_ELE_TAG, "add", PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addObjectCreate(addListElementTag, PUT_ATTRIBUTE_HANDLER_CLASS);
+ digester.addRule(addListElementTag, new FillAttributeRule());
+ digester.addSetNext(addListElementTag, "add", PUT_ATTRIBUTE_HANDLER_CLASS);
}
}
Added: tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/package.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/package.html?view=auto&rev=555316
==============================================================================
--- tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/package.html (added)
+++ tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/package.html Wed Jul 11 08:57:06 2007
@@ -0,0 +1,30 @@
+<!--
+/*
+ * $Id$
+ *
+ * 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.
+ */
+-->
+<html>
+<head>
+ <title>Old-format Tiles definition files loading</title>
+</head>
+<body>
+Contains code to read old-format Tiles definition files.
+</body>
+</html>
\ No newline at end of file
Propchange: tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/compat/definition/digester/package.html
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-1.1.xml
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-1.1.xml?view=auto&rev=555316
==============================================================================
--- tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-1.1.xml (added)
+++ tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-1.1.xml Wed Jul 11 08:57:06 2007
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+/*
+ * $Id: tiles-defs.xml 535861 2007-05-07 11:46:54Z apetrelli $
+ *
+ * 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.
+ */
+-->
+
+ <!DOCTYPE tiles-definitions PUBLIC
+ "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/tiles-config_1_1.dtd">
+
+<!-- Definitions for Tiles documentation -->
+
+<tiles-definitions>
+
+ <!-- ======================================================= -->
+ <!-- Master definition -->
+ <!-- ======================================================= -->
+
+ <!-- Doc index page description -->
+ <definition name="doc.mainLayout" template="/layout/classicLayout.jsp">
+ <put name="title" value="Tiles Library Documentation" />
+ <put name="header" value="/common/header.jsp" />
+ <put name="menu" value="doc.menu.main" />
+ <put name="footer" value="/common/footer.jsp" />
+ <put name="body" value="doc.portal.body" />
+ <put name="bean" value="This is an object" type="string" />
+ </definition>
+
+ <!-- ======================================================= -->
+ <!-- Main page body definitions -->
+ <!-- ======================================================= -->
+
+ <definition name="doc.portal.body" template="/layout/columnsLayout.jsp">
+ <put name="numCols" value="2" />
+ <putList name="list0" >
+ <add value="/doc/portal/welcome.jsp" />
+ <add value="/doc/portal/features.jsp" />
+ <!--<add value="/doc/portal/todo.jsp" /> -->
+ <add value="/doc/portal/documentation.jsp" />
+ </putList>
+ <putList name="list1" >
+ <add value="/doc/portal/news.jsp" />
+ <add value="/doc/portal/download.jsp" />
+ <add value="/doc/portal/tilesCompsTemplates.jsp" />
+ <add value="/doc/portal/strutsIntegration.jsp" />
+ <add value="/doc/portal/comments.jsp" />
+ <add value="/doc/portal/revisions.jsp" />
+ </putList>
+ </definition>
+
+ <!-- ======================================================= -->
+ <!-- Menus definitions -->
+ <!-- ======================================================= -->
+
+ <!-- Menu bar definition -->
+<definition name="doc.menu.main" template="/layout/vboxLayout.jsp" >
+ <putList name="componentsList" >
+ <add value="doc.menu.links" />
+ <add value="doc.menu.taglib.references" />
+ <add value="doc.menu.printer.friendly" />
+ <add value="doc.menu.old.documents" />
+ </putList>
+</definition>
+
+ <!-- Documentation menu definition v1.1-->
+<definition name="doc.menu.links" template="/layouts/menu.jsp" >
+ <put name="title" value="Documentation" />
+ <putList name="items" >
+ <item value="Home" link="/index.jsp" />
+ <item value="Live Examples (new)" link="/examples/index.jsp" />
+ <!--
+ <item> <value>Commented Examples</value>
+ <link>/examples/index.jsp</link>
+ <classtype>org.apache.tiles.beans.SimpleMenuItem</classtype>
+ </item>
+ -->
+ <item value="Quick overview" link="/doc/quickOverview.jsp" />
+ <!--
+ <item value="Tutorial" link="/doc/tutorial.jsp" />
+ -->
+ <item value="Tutorial Live Examples" link="/tutorial/index.jsp" />
+ <item value="Download" link="/doc/download.jsp" />
+ <item value="Installation" link="/doc/installation.jsp" />
+ <item value="User Guide" link="/doc/userGuide.jsp" />
+ <item value="Javadoc" link="/api/index.html" />
+ <item value="Struts Home" link="http://www.apache.org" icon="/images/struts-power.gif"
+ classtype="org.apache.tiles.beans.SimpleMenuItem" />
+ </putList>
+</definition>
+
+ <!-- Printer friendly menu definition -->
+<definition name="doc.menu.printer.friendly" template="/layouts/menu.jsp" >
+ <put name="title" value="Printer Versions" />
+ <putList name="items" >
+ <item value="Quick Overview" link="/test/testAll.jsp" />
+ <item value="Tutorial" link="/doc/tutorialBody.html" />
+ <item value="User Guide" link="/doc/userGuideBody.html" />
+ <item value="Overview (old)" link="/doc/overviewBody.html" />
+ </putList>
+</definition>
+
+ <!-- Taglib menu definition -->
+<definition name="doc.menu.taglib.references" template="/layouts/menu.jsp" >
+ <put name="title" value="Tag Library Reference" />
+ <putList name="items" >
+ <item value="Tiles Tags" link="/doc/tilesTags.jsp" />
+ <!-- <item value="Extension Tags (old)" link="/doc/extensionsTags.jsp" /> -->
+ </putList>
+</definition>
+
+ <!-- Oldies menu definition -->
+<definition name="doc.menu.old.documents" template="/layouts/menu.jsp" >
+ <put name="title" value="Old Documents" />
+ <putList name="items" >
+ <item value="Overview (old)" link="/doc/overview.jsp" />
+ </putList>
+</definition>
+
+
+</tiles-definitions>
Added: tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-2.0.xml
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-2.0.xml?view=auto&rev=555316
==============================================================================
--- tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-2.0.xml (added)
+++ tiles/framework/trunk/tiles-compat/src/main/java/org/apache/tiles/config/tiles-defs-2.0.xml Wed Jul 11 08:57:06 2007
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+/*
+ * $Id: tiles-defs.xml 535861 2007-05-07 11:46:54Z apetrelli $
+ *
+ * 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.
+ */
+-->
+
+ <!DOCTYPE tiles-definitions PUBLIC
+ "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
+ "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
+
+<!-- Definitions for Tiles documentation -->
+
+<tiles-definitions>
+
+ <!-- ======================================================= -->
+ <!-- Master definition -->
+ <!-- ======================================================= -->
+
+ <!-- Doc index page description -->
+ <definition name="doc.mainLayout" template="/layout/classicLayout.jsp">
+ <put-attribute name="title" value="Tiles Library Documentation" />
+ <put-attribute name="header" value="/common/header.jsp" />
+ <put-attribute name="menu" value="doc.menu.main" />
+ <put-attribute name="footer" value="/common/footer.jsp" />
+ <put-attribute name="body" value="doc.portal.body" />
+ <put-attribute name="bean" value="This is an object" type="object" />
+ </definition>
+
+ <!-- ======================================================= -->
+ <!-- Main page body definitions -->
+ <!-- ======================================================= -->
+
+ <definition name="doc.portal.body" template="/layout/columnsLayout.jsp">
+ <put-attribute name="numCols" value="2" />
+ <put-list-attribute name="list0" >
+ <add-attribute value="/doc/portal/welcome.jsp" />
+ <add-attribute value="/doc/portal/features.jsp" />
+ <!--<add-attribute value="/doc/portal/todo.jsp" /> -->
+ <add-attribute value="/doc/portal/documentation.jsp" />
+ </put-list-attribute>
+ <put-list-attribute name="list1" >
+ <add-attribute value="/doc/portal/news.jsp" />
+ <add-attribute value="/doc/portal/download.jsp" />
+ <add-attribute value="/doc/portal/tilesCompsTemplates.jsp" />
+ <add-attribute value="/doc/portal/strutsIntegration.jsp" />
+ <add-attribute value="/doc/portal/comments.jsp" />
+ <add-attribute value="/doc/portal/revisions.jsp" />
+ </put-list-attribute>
+ </definition>
+
+ <!-- ======================================================= -->
+ <!-- Menus definitions -->
+ <!-- ======================================================= -->
+
+ <!-- Menu bar definition -->
+<definition name="doc.menu.main" template="/layout/vboxLayout.jsp" >
+ <put-list-attribute name="componentsList" >
+ <add-attribute value="doc.menu.links" />
+ <add-attribute value="doc.menu.taglib.references" />
+ <add-attribute value="doc.menu.printer.friendly" />
+ <add-attribute value="doc.menu.old.documents" />
+ </put-list-attribute>
+</definition>
+
+ <!-- Documentation menu definition v1.1-->
+<definition name="doc.menu.links" template="/layouts/menu.jsp" >
+ <put-attribute name="title" value="Documentation" />
+ <put-list-attribute name="items" >
+ <item value="Home" link="/index.jsp" />
+ <item value="Live Examples (new)" link="/examples/index.jsp" />
+ <!--
+ <item> <value>Commented Examples</value>
+ <link>/examples/index.jsp</link>
+ <classtype>org.apache.tiles.beans.SimpleMenuItem</classtype>
+ </item>
+ -->
+ <item value="Quick overview" link="/doc/quickOverview.jsp" />
+ <!--
+ <item value="Tutorial" link="/doc/tutorial.jsp" />
+ -->
+ <item value="Tutorial Live Examples" link="/tutorial/index.jsp" />
+ <item value="Download" link="/doc/download.jsp" />
+ <item value="Installation" link="/doc/installation.jsp" />
+ <item value="User Guide" link="/doc/userGuide.jsp" />
+ <item value="Javadoc" link="/api/index.html" />
+ <item value="Struts Home" link="http://www.apache.org" icon="/images/struts-power.gif"
+ classtype="org.apache.tiles.beans.SimpleMenuItem" />
+ </put-list-attribute>
+</definition>
+
+ <!-- Printer friendly menu definition -->
+<definition name="doc.menu.printer.friendly" template="/layouts/menu.jsp" >
+ <put-attribute name="title" value="Printer Versions" />
+ <put-list-attribute name="items" >
+ <item value="Quick Overview" link="/test/testAll.jsp" />
+ <item value="Tutorial" link="/doc/tutorialBody.html" />
+ <item value="User Guide" link="/doc/userGuideBody.html" />
+ <item value="Overview (old)" link="/doc/overviewBody.html" />
+ </put-list-attribute>
+</definition>
+
+ <!-- Taglib menu definition -->
+<definition name="doc.menu.taglib.references" template="/layouts/menu.jsp" >
+ <put-attribute name="title" value="Tag Library Reference" />
+ <put-list-attribute name="items" >
+ <item value="Tiles Tags" link="/doc/tilesTags.jsp" />
+ <!-- <item value="Extension Tags (old)" link="/doc/extensionsTags.jsp" /> -->
+ </put-list-attribute>
+</definition>
+
+ <!-- Oldies menu definition -->
+<definition name="doc.menu.old.documents" template="/layouts/menu.jsp" >
+ <put-attribute name="title" value="Old Documents" />
+ <put-list-attribute name="items" >
+ <item value="Overview (old)" link="/doc/overview.jsp" />
+ </put-list-attribute>
+</definition>
+
+
+</tiles-definitions>
Added: tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/TestCompatibilityDigesterDefinitionsReader.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/TestCompatibilityDigesterDefinitionsReader.java?view=auto&rev=555316
==============================================================================
--- tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/TestCompatibilityDigesterDefinitionsReader.java (added)
+++ tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/TestCompatibilityDigesterDefinitionsReader.java Wed Jul 11 08:57:06 2007
@@ -0,0 +1,178 @@
+/*
+ * $Id$
+ *
+ * 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.tiles.compat.definition.digester;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.Definition;
+import org.apache.tiles.definition.DefinitionsFactoryException;
+import org.apache.tiles.definition.DefinitionsReader;
+
+/**
+ * Tests the <code>org.apache.tiles.definition.digester.DigesterDefinitionsReader</code> class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestCompatibilityDigesterDefinitionsReader extends TestCase {
+
+ /**
+ * The logging object.
+ */
+ private static final Log LOG = LogFactory
+ .getLog(TestCompatibilityDigesterDefinitionsReader.class);
+
+ /**
+ * Creates a new instance of TestDigesterDefinitionsReader.
+ *
+ * @param name The name of the test.
+ */
+ public TestCompatibilityDigesterDefinitionsReader(String name) {
+ super(name);
+ }
+
+ /**
+ * @return a test suite (<code>TestSuite</code>) that includes all methods
+ * starting with "test"
+ */
+ public static Test suite() {
+ return new TestSuite(TestCompatibilityDigesterDefinitionsReader.class);
+ }
+
+ /**
+ * Tests the read method to read Tiles 1.1 files.
+ */
+ public void testReadOldFormat() {
+ try {
+ DefinitionsReader reader = new CompatibilityDigesterDefinitionsReader();
+ reader.init(new HashMap<String, String>());
+
+ URL configFile = this.getClass().getClassLoader().getResource(
+ "org/apache/tiles/config/tiles-defs-1.1.xml");
+ assertNotNull("Config file not found", configFile);
+
+ InputStream source = configFile.openStream();
+ Map<String, Definition> definitions = reader.read(source);
+
+ assertNotNull("Definitions not returned.", definitions);
+ assertNotNull("Couldn't find doc.mainLayout tile.",
+ definitions.get("doc.mainLayout"));
+ assertNotNull("Couldn't Find title attribute.", definitions.get(
+ "doc.mainLayout").getAttribute("title").getValue());
+ assertEquals("Incorrect Find title attribute.",
+ "Tiles Library Documentation", definitions.get(
+ "doc.mainLayout").getAttribute("title").getValue());
+
+ } catch (Exception e) {
+ fail("Exception reading configuration." + e);
+ }
+ }
+
+ /**
+ * Tests the read method to read Tiles 2.0 files.
+ */
+ public void testReadNewFormat() {
+ try {
+ DefinitionsReader reader = new CompatibilityDigesterDefinitionsReader();
+ reader.init(new HashMap<String, String>());
+
+ URL configFile = this.getClass().getClassLoader().getResource(
+ "org/apache/tiles/config/tiles-defs-2.0.xml");
+ assertNotNull("Config file not found", configFile);
+
+ InputStream source = configFile.openStream();
+ Map<String, Definition> definitions = reader.read(source);
+
+ assertNotNull("Definitions not returned.", definitions);
+ assertNotNull("Couldn't find doc.mainLayout tile.",
+ definitions.get("doc.mainLayout"));
+ assertNotNull("Couldn't Find title attribute.", definitions.get(
+ "doc.mainLayout").getAttribute("title").getValue());
+ assertEquals("Incorrect Find title attribute.",
+ "Tiles Library Documentation", definitions.get(
+ "doc.mainLayout").getAttribute("title").getValue());
+
+ } catch (Exception e) {
+ fail("Exception reading configuration." + e);
+ }
+ }
+
+ /**
+ * Tests calling read without calling init.
+ */
+ public void testNoInit() {
+ try {
+ DefinitionsReader reader = new CompatibilityDigesterDefinitionsReader();
+
+ // What happens if we don't call init?
+ // reader.init(new HashMap());
+
+ URL configFile = this.getClass().getClassLoader().getResource(
+ "org/apache/tiles/config/tiles-defs-1.1.xml");
+ assertNotNull("Config file not found", configFile);
+
+ InputStream source = configFile.openStream();
+ reader.read(source);
+
+ fail("Should've thrown exception.");
+ } catch (DefinitionsFactoryException e) {
+ // correct.
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Exception caught, it is OK", e);
+ }
+ } catch (Exception e) {
+ fail("Exception reading configuration." + e);
+ }
+ }
+
+ /**
+ * Tests read with bad input source.
+ */
+ public void testBadSource() {
+ try {
+ // Create Digester Reader.
+ DefinitionsReader reader = new CompatibilityDigesterDefinitionsReader();
+ Map<String, String> params = new HashMap<String, String>();
+
+ // Initialize reader.
+ reader.init(params);
+
+ // Read definitions.
+ reader.read(new String("Bad Input"));
+ fail("Should've thrown an exception.");
+ } catch (DefinitionsFactoryException e) {
+ // correct.
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Exception caught, it is OK", e);
+ }
+ } catch (Exception e) {
+ fail("Exception reading configuration." + e);
+ }
+ }
+}
Propchange: tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/TestCompatibilityDigesterDefinitionsReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/framework/trunk/tiles-compat/src/test/java/org/apache/tiles/compat/definition/digester/TestCompatibilityDigesterDefinitionsReader.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java?view=diff&rev=555316&r1=555315&r2=555316
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java Wed Jul 11 08:57:06 2007
@@ -139,8 +139,11 @@
* Digester rule to manage attribute filling.
*/
public static class FillAttributeRule extends Rule {
-
- public FillAttributeRule() {};
+
+ /**
+ * Constructor.
+ */
+ public FillAttributeRule() { };
/** {@inheritDoc} */
@Override
@@ -284,6 +287,12 @@
inited = true;
}
+ /**
+ * Initialised the syntax for reading XML files containing Tiles
+ * definitions.
+ *
+ * @param digester The digester to initialize.
+ */
protected void initSyntax(Digester digester) {
initDigesterForTilesDefinitionsSyntax(digester);
}