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 2009/07/21 21:18:19 UTC

svn commit: r796479 - in /tiles/framework/trunk/src/site/apt: tutorial/advanced/wildcard.apt whats-new.apt

Author: apetrelli
Date: Tue Jul 21 19:18:18 2009
New Revision: 796479

URL: http://svn.apache.org/viewvc?rev=796479&view=rev
Log:
TILES-433
Added docs for pattern matching with Regexp.

Modified:
    tiles/framework/trunk/src/site/apt/tutorial/advanced/wildcard.apt
    tiles/framework/trunk/src/site/apt/whats-new.apt

Modified: tiles/framework/trunk/src/site/apt/tutorial/advanced/wildcard.apt
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/src/site/apt/tutorial/advanced/wildcard.apt?rev=796479&r1=796478&r2=796479&view=diff
==============================================================================
--- tiles/framework/trunk/src/site/apt/tutorial/advanced/wildcard.apt (original)
+++ tiles/framework/trunk/src/site/apt/tutorial/advanced/wildcard.apt Tue Jul 21 19:18:18 2009
@@ -38,14 +38,42 @@
 </definition>
 ------------------------------------
 
-  * the regular expression style (notice the ~ character that indicates that a regexp will be used), available by calling
-  {{{../../apidocs/org/apache/tiles/definition/dao/CachingLocaleUrlDefinitionDAO.html#setPatternDefinitionResolver(org.apache.tiles.definition.pattern.PatternDefinitionResolver)}CachingLocaleUrlDefinitionDAO.setPatternDefinitionResolver}}
-  with an instance of
-  {{{../../apidocs/org/apache/tiles/definition/pattern/RegexpPatternDefinitionResolver.html}RegexpPatternDefinitionResolver}}
-  :
+* {Using different pattern matching languages}
+
+  In Tiles 2.2 it is possible to use different pattern matching languages
+  at the same time. Tiles supports Wildcard and Regular Expressions natively.
+
+  To configure it, override the
+  {{{../../apidocs/org/apache/tiles/factory/BasicTilesContainerFactory.html#createPatternDefinitionResolver(java.lang.Class)}createPatternDefinitionResolver}}
+  method of <<<BasicTilesContainerFactory>>> this way:
+
+-------------------------------------
+@Override
+protected <T> PatternDefinitionResolver<T> createPatternDefinitionResolver(
+        Class<T> customizationKeyClass) {
+    DefinitionPatternMatcherFactory wildcardFactory = new WildcardDefinitionPatternMatcherFactory();
+    DefinitionPatternMatcherFactory regexpFactory = new RegexpDefinitionPatternMatcherFactory();
+    PrefixedPatternDefinitionResolver<T> resolver = new PrefixedPatternDefinitionResolver<T>();
+    resolver.registerDefinitionPatternMatcherFactory("WILDCARD", wildcardFactory);
+    resolver.registerDefinitionPatternMatcherFactory("REGEXP", regexpFactory);
+    return resolver;
+}
+-------------------------------------
+
+  Now you can still use Wildcard notation, but remember to add the <<<WILDCARD:>>> prefix:
+
+------------------------------------
+<definition name="WILDCARD: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>
+------------------------------------
+
+  And, if you want to use Regular Expressions:
 
 ------------------------------------
-<definition name="~test\.definition(.*)\.message(.*)" template="/layout{1}.jsp">
+<definition name="REGEXP: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"/>

Modified: tiles/framework/trunk/src/site/apt/whats-new.apt
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/src/site/apt/whats-new.apt?rev=796479&r1=796478&r2=796479&view=diff
==============================================================================
--- tiles/framework/trunk/src/site/apt/whats-new.apt (original)
+++ tiles/framework/trunk/src/site/apt/whats-new.apt Tue Jul 21 19:18:18 2009
@@ -35,8 +35,8 @@
 
   * {{{tutorial/integration/velocity.html}Support for Velocity}}.
 
-  * Support for wildcard mathing using
-  {{{tutorial/advanced/wildcard.html}regular expressions}}.
+  * Support for pattern matching using
+  {{{tutorial/advanced/wildcard.html#Using_different_pattern_matching_languages}regular expressions}}.
 
   * {{{tutorial/advanced/el-support.html#OGNL_Support}OGNL support}}
   and