You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2005/07/07 03:41:07 UTC

svn commit: r209560 - in /struts/shale/trunk/core-library: build.xml src/java/org/apache/shale/tiles/Bundle.properties src/java/org/apache/shale/tiles/TilesViewHandler.java src/java/org/apache/shale/tiles/package.html

Author: craigmcc
Date: Wed Jul  6 18:41:06 2005
New Revision: 209560

URL: http://svn.apache.org/viewcvs?rev=209560&view=rev
Log:
Decouple the Shale Tiles integration layer from the remainder of Shale, so
that shale-tiles.jar can be used to link Tiles with *any* JSF implementation.

Added:
    struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/Bundle.properties
Modified:
    struts/shale/trunk/core-library/build.xml
    struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/TilesViewHandler.java
    struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/package.html

Modified: struts/shale/trunk/core-library/build.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/build.xml?rev=209560&r1=209559&r2=209560&view=diff
==============================================================================
--- struts/shale/trunk/core-library/build.xml (original)
+++ struts/shale/trunk/core-library/build.xml Wed Jul  6 18:41:06 2005
@@ -212,6 +212,7 @@
     <echo  message="jsfri.present =  ${jsfri.present}"/>
     <echo  message="myfaces.present= ${myfaces.present}"/>
     <echo  message="spring.present=  ${spring.present}"/>
+    <echo  message="tiles.present=   ${tiles.present}"/>
   </target>
 
 

Added: struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/Bundle.properties
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/Bundle.properties?rev=209560&view=auto
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/Bundle.properties (added)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/Bundle.properties Wed Jul  6 18:41:06 2005
@@ -0,0 +1,23 @@
+# Resource Strings for Shale Tiles Integration
+#
+# Copyright 2004-2005 The Apache Software Foundation.
+#
+# Licensed 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.
+#
+# $Id$
+
+# org.apache.shale.tiles.TilesViewHandler
+tiles.renderingView=Rendering view {0}, looking for tile {1}
+tiles.dispatchingToTile=Dispatching to tile {0}
+tiles.dispatchingToViewHandler=Dispatching {0} to the default view handler
+

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/TilesViewHandler.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/TilesViewHandler.java?rev=209560&r1=209559&r2=209560&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/TilesViewHandler.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/TilesViewHandler.java Wed Jul  6 18:41:06 2005
@@ -20,8 +20,11 @@
 import org.apache.commons.logging.LogFactory;
 
 import java.io.IOException;
+import java.text.MessageFormat;
 import java.util.List;
 import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
 
 import javax.faces.application.ViewHandler;
 
@@ -34,9 +37,12 @@
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 
-import org.apache.tiles.*;
-
-import org.apache.shale.util.Messages;
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.ComponentDefinition;
+import org.apache.tiles.DefinitionsFactory;
+import org.apache.tiles.DefinitionsFactoryException;
+import org.apache.tiles.NoSuchDefinitionException;
+import org.apache.tiles.TilesUtil;
 
 /**
  * This view handler strips the suffix off of the view ID and looks
@@ -86,6 +92,12 @@
 
     
    /**
+    * <p><code>MessageFormat</code> used to perform parameter substitution.</p>
+    */
+   private MessageFormat format = new MessageFormat("");
+
+
+   /**
     * <p>Log instance for this class.</p>
     */
    private static final Log log = LogFactory.getLog(
@@ -93,9 +105,10 @@
    /**
     * <p>Message resources for this class.</p>
     */
-   private static Messages messages = 
-      new Messages("org.apache.shale.Bundle",
-                   TilesViewHandler.class.getClassLoader());
+   private static ResourceBundle bundle =
+      ResourceBundle.getBundle("org.apache.shale.tiles.Bundle",
+                               Locale.getDefault(),
+                               TilesViewHandler.class.getClassLoader());
 
     /**
      * <p>The default JSF view handler.</p>
@@ -122,21 +135,48 @@
       ComponentDefinition tile = getTile(tileName);
 
       if (log.isDebugEnabled()) {
-         log.debug(messages.getMessage("tiles.renderingView", 
-                                       new Object[] { viewId, tileName }));
+         String message = null;
+         try {
+             message = bundle.getString("tiles.renderingView");
+         } catch (MissingResourceException e) {
+             message = "Rendering view {0}, looking for tile {1}";
+         }
+         synchronized(format) {
+            format.applyPattern(message);
+            message = format.format(new Object[] { viewId, tileName });
+         }
+         log.debug(message);
       }
 
       if (tile != null) {
          if (log.isDebugEnabled()) {
-            log.debug(messages.getMessage("tiles.dispatchingToTile", 
-                                          new Object[] { tileName }));
+            String message = null;
+            try {
+                message = bundle.getString("tiles.dispatchingToTile");
+            } catch (MissingResourceException e) {
+                message = "Dispatching to tile {0}";
+            }
+            synchronized(format) {
+               format.applyPattern(message);
+               message = format.format(new Object[] { tileName });
+            }
+            log.debug(message);
          }
          dispatchToTile(facesContext.getExternalContext(), tile);
       }
       else {
          if (log.isDebugEnabled()) {
-            log.debug(messages.getMessage("tiles.dispatchingToViewHandler", 
-                                          new Object[] { viewId }));
+            String message = null;
+            try {
+                message = bundle.getString("tiles.dispatchingToViewHandler");
+            } catch (MissingResourceException e) {
+                message = "Dispatching {0} to the default view handler";
+            }
+            synchronized(format) {
+               format.applyPattern(message);
+               message = format.format(new Object[] { viewId });
+            }
+            log.debug(message);
          }
          defaultViewHandler.renderView(facesContext, viewToRender);
       }

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/package.html
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/package.html?rev=209560&r1=209559&r2=209560&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/package.html (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/tiles/package.html Wed Jul  6 18:41:06 2005
@@ -19,10 +19,15 @@
 <body>
 
 <p>This package contains an optional integration layer for working with standalone Tiles.
-<p>
-<strong>Note:</strong><i> Shale's Tiles integration works only with standalone Tiles, which currently resides in the Struts sandbox. Shale's Tiles integration does not work with Struts Tiles.</i>
-<p>
-Using Shale's Tiles integration is easy: you just include <code>shale-tiles.jar</code> in <code>WEB-INF/lib</code>. For your efforts, for every view ID that you specify for JSF navigation, Shale:
+It has <strong>NO</strong> dependencies on the remainder of Shale, so the JAR file containing
+it (<code>shale-tiles.jar</code>) may be used to integrate Tiles with any implementation
+of JavaServer Faces.</p>
+
+<p><strong>Note:</strong><i> Shale's Tiles integration works only with standalone Tiles,
+which currently resides in the Struts sandbox.  Shale's Tiles integration does not work
+with Struts Tiles.</i><p>
+
+<p>Using Shale's Tiles integration is easy: you just include <code>shale-tiles.jar</code> in <code>WEB-INF/lib</code>. For your efforts, for every view ID that you specify for JSF navigation, Shale:
 <ol><li>Strips off the view ID's suffix (eg: "/tiles/test.jsp" becomes "/tiles/test")</li>
 <li>Searches for a tile with the resulting name, with or without the leading slash (eg: "/tiles/test" or "tiles/test")</li>
 <li>Loads the tile if found; otherwise, delegates to the default JSF navigation handler</li>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org