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 2008/06/26 20:26:55 UTC
svn commit: r671976 - in /tiles/framework/trunk:
tiles-core/src/main/java/org/apache/tiles/factory/
tiles-test/src/main/java/org/apache/tiles/test/factory/
tiles-test/src/main/webapp/ tiles-test/src/main/webapp/WEB-INF/
tiles-test/src/test/selenium/
Author: apetrelli
Date: Thu Jun 26 11:26:55 2008
New Revision: 671976
URL: http://svn.apache.org/viewvc?rev=671976&view=rev
Log:
TILES-220
Improved BasicTilesContainerFactory to ease customization.
Added Selenium test.
Added:
tiles/framework/trunk/tiles-test/src/main/webapp/layoutOne.jsp (with props)
tiles/framework/trunk/tiles-test/src/main/webapp/layoutTwo.jsp (with props)
tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_wildcard.jsp (with props)
tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionWildcardTest.html (with props)
Modified:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestAlternateTilesContainerFactory.java
tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/tiles-defs-alt.xml
tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp
tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java?rev=671976&r1=671975&r2=671976&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java Thu Jun 26 11:26:55 2008
@@ -37,6 +37,7 @@
import org.apache.tiles.definition.LocaleDefinitionsFactory;
import org.apache.tiles.definition.Refreshable;
import org.apache.tiles.definition.UrlDefinitionsFactory;
+import org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO;
import org.apache.tiles.definition.dao.DefinitionDAO;
import org.apache.tiles.definition.dao.LocaleUrlDefinitionDAO;
import org.apache.tiles.definition.digester.DigesterDefinitionsReader;
@@ -199,6 +200,23 @@
return new UrlDefinitionsFactory();
}
+
+ /**
+ * Instantiate (and does not initialize) a Locale-based definition DAO.
+ *
+ * @param context The context.
+ * @param applicationContext The Tiles application context.
+ * @param contextFactory The Tiles context factory.
+ * @param resolver The locale resolver.
+ * @return The definition DAO.
+ * @since 2.1.0
+ */
+ protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(Object context,
+ TilesApplicationContext applicationContext,
+ TilesContextFactory contextFactory, LocaleResolver resolver) {
+ return new LocaleUrlDefinitionDAO();
+ }
+
/**
* Creates a Locale-based definition DAO.
*
@@ -212,13 +230,16 @@
protected DefinitionDAO<Locale> createLocaleDefinitionDao(Object context,
TilesApplicationContext applicationContext,
TilesContextFactory contextFactory, LocaleResolver resolver) {
- LocaleUrlDefinitionDAO definitionDao = new LocaleUrlDefinitionDAO();
+ BaseLocaleUrlDefinitionDAO definitionDao = instantiateLocaleDefinitionDao(
+ context, applicationContext, contextFactory, resolver);
definitionDao.setReader(createDefinitionsReader(context, applicationContext,
contextFactory));
definitionDao.setSourceURLs(getSourceURLs(context, applicationContext,
contextFactory));
+ definitionDao.setApplicationContext(applicationContext);
return definitionDao;
}
+
/**
* Creates the locale resolver. By default it creates a
* {@link DefaultLocaleResolver}.
Modified: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestAlternateTilesContainerFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestAlternateTilesContainerFactory.java?rev=671976&r1=671975&r2=671976&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestAlternateTilesContainerFactory.java (original)
+++ tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestAlternateTilesContainerFactory.java Thu Jun 26 11:26:55 2008
@@ -29,6 +29,10 @@
import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.context.TilesContextFactory;
import org.apache.tiles.definition.DefinitionsFactoryException;
+import org.apache.tiles.definition.LocaleDefinitionsFactory;
+import org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO;
+import org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO;
+import org.apache.tiles.locale.LocaleResolver;
/**
* Test alternate Tiles container factory to customize Tiles behaviour.
@@ -56,4 +60,20 @@
}
return urls;
}
+
+ /** {@inheritDoc} */
+ @Override
+ protected LocaleDefinitionsFactory instantiateDefinitionsFactory(
+ Object context, TilesApplicationContext applicationContext,
+ TilesContextFactory contextFactory, LocaleResolver resolver) {
+ return new LocaleDefinitionsFactory();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(
+ Object context, TilesApplicationContext applicationContext,
+ TilesContextFactory contextFactory, LocaleResolver resolver) {
+ return new CachingLocaleUrlDefinitionDAO();
+ }
}
Modified: tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/tiles-defs-alt.xml
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/tiles-defs-alt.xml?rev=671976&r1=671975&r2=671976&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/tiles-defs-alt.xml (original)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/tiles-defs-alt.xml Thu Jun 26 11:26:55 2008
@@ -32,4 +32,9 @@
<put-attribute name="header" value="/header.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
</definition>
+ <definition name="test.definition*.message*" template="/layout{1}.jsp">
+ <put-attribute name="title" value="This definition has a message: {2}."/>
+ <put-attribute name="header" value="/header.jsp"/>
+ <put-attribute name="body" value="/body.jsp"/>
+ </definition>
</tiles-definitions>
Modified: tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp?rev=671976&r1=671975&r2=671976&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp (original)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp Thu Jun 26 11:26:55 2008
@@ -59,6 +59,7 @@
<a href="testinsertnestedlistdefinition_tags.jsp">Test Insert Nested List Definition only using JSP tags</a><br/>
<a href="testinsertdefinition_el.jsp">Test Insert Configured Definition with EL</a><br/>
<a href="testinsertdefinition_openbody.jsp">Test Insert Configured Definition with Open Body</a><br/>
+ <a href="testinsertdefinition_wildcard.jsp">Test Insert Configured Definition with Wildcards</a><br/>
<a href="testput.jsp">Test Put Tag</a><br/>
<a href="testput_flush.jsp">Test Put Tag with Flush</a><br/>
<a href="testput_el.jsp">Test Put Tag using EL</a><br/>
Added: tiles/framework/trunk/tiles-test/src/main/webapp/layoutOne.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/layoutOne.jsp?rev=671976&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/layoutOne.jsp (added)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/layoutOne.jsp Thu Jun 26 11:26:55 2008
@@ -0,0 +1,40 @@
+<%@ page session="false" %>
+<%--
+/*
+ * $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.
+ *
+ */
+--%>
+<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
+
+<table border="2" width="300" bordercolor="Gray">
+ <tr>
+ <td bgcolor="yellow">This is layout one.</td>
+ </tr>
+ <tr>
+ <td bgcolor="Blue"><strong><tiles:getAsString name="title"/></strong></td>
+ </tr>
+ <tr>
+ <td><tiles:insertAttribute name="header"/></td>
+ </tr>
+ <tr>
+ <td><tiles:insertAttribute name="body"/></td>
+ </tr>
+</table>
\ No newline at end of file
Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/layoutOne.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/layoutOne.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/framework/trunk/tiles-test/src/main/webapp/layoutTwo.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/layoutTwo.jsp?rev=671976&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/layoutTwo.jsp (added)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/layoutTwo.jsp Thu Jun 26 11:26:55 2008
@@ -0,0 +1,40 @@
+<%@ page session="false" %>
+<%--
+/*
+ * $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.
+ *
+ */
+--%>
+<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
+
+<table border="2" width="300" bordercolor="Gray">
+ <tr>
+ <td bgcolor="yellow">This is layout two.</td>
+ </tr>
+ <tr>
+ <td bgcolor="Blue"><strong><tiles:getAsString name="title"/></strong></td>
+ </tr>
+ <tr>
+ <td><tiles:insertAttribute name="header"/></td>
+ </tr>
+ <tr>
+ <td><tiles:insertAttribute name="body"/></td>
+ </tr>
+</table>
\ No newline at end of file
Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/layoutTwo.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/layoutTwo.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_wildcard.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_wildcard.jsp?rev=671976&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_wildcard.jsp (added)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_wildcard.jsp Thu Jun 26 11:26:55 2008
@@ -0,0 +1,28 @@
+<%@ page session="false" %>
+<%--
+/*
+ * $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.
+ *
+ */
+--%>
+<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
+<tiles:setCurrentContainer containerKey="alternate" />
+<tiles:insertDefinition name="test.definitionOne.messageHello" />
+<tiles:insertDefinition name="test.definitionTwo.messageBye" />
Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_wildcard.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_wildcard.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionWildcardTest.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionWildcardTest.html?rev=671976&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionWildcardTest.html (added)
+++ tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionWildcardTest.html Thu Jun 26 11:26:55 2008
@@ -0,0 +1,76 @@
+<!--
+/*
+ * $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>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Configured Definition Wildcard Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Configured Definition Wildcard Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/tiles-test/index.jsp</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Test Insert Configured Definition with Wildcards</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertTextPresent</td>
+ <td>This is layout one.</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertTextPresent</td>
+ <td>This is layout two.</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertTextPresent</td>
+ <td>This definition has a message: Hello.</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertTextPresent</td>
+ <td>This definition has a message: Bye.</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertTextPresent</td>
+ <td>This is the header</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertTextPresent</td>
+ <td>This is a body</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionWildcardTest.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionWildcardTest.html
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html?rev=671976&r1=671975&r2=671976&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html (original)
+++ tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html Thu Jun 26 11:26:55 2008
@@ -103,6 +103,9 @@
<td><a href="ConfiguredDefinitionOpenBodyTest.html">Configured Definition with Open Body Test</a></td>
</tr>
<tr>
+ <td><a href="ConfiguredDefinitionWildcardTest.html">Configured Definition Wildcard Test</a></td>
+ </tr>
+ <tr>
<td><a href="PutTagTest.html">Put Tag Test</a></td>
</tr>
<tr>