You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2009/09/13 19:44:49 UTC

svn commit: r814355 - in /incubator/jspwiki/trunk: src/WebContent/WEB-INF/lib/ src/java/org/apache/wiki/ui/stripes/ tests/java/org/apache/wiki/ui/stripes/

Author: ajaquith
Date: Sun Sep 13 17:44:49 2009
New Revision: 814355

URL: http://svn.apache.org/viewvc?rev=814355&view=rev
Log:
Upgraded Stripes to 1.5.2-beta, which fixes an important layout bug. Added a WikiPageFormatter class that will render WikiPage objects passed to Stripes tags as the page name, rather than contents of toString().

Added:
    incubator/jspwiki/trunk/src/WebContent/WEB-INF/lib/stripes-1.5.2-beta.jar   (with props)
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageFormatter.java
Removed:
    incubator/jspwiki/trunk/src/WebContent/WEB-INF/lib/stripes-1.5.1.jar
Modified:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/FileBasedActionResolver.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/FileBasedActionResolverTest.java

Added: incubator/jspwiki/trunk/src/WebContent/WEB-INF/lib/stripes-1.5.2-beta.jar
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/WEB-INF/lib/stripes-1.5.2-beta.jar?rev=814355&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/jspwiki/trunk/src/WebContent/WEB-INF/lib/stripes-1.5.2-beta.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/FileBasedActionResolver.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/FileBasedActionResolver.java?rev=814355&r1=814354&r2=814355&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/FileBasedActionResolver.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/FileBasedActionResolver.java Sun Sep 13 17:44:49 2009
@@ -124,7 +124,8 @@
         // Must be a new ActionBean we haven't processed yet, AND we have a
         // binding for it.
         UrlBinding prototype = UrlBindingFactory.parseUrlBinding( clazz, binding );
-        UrlBindingFactory.getInstance().addBinding( clazz, prototype );
+        UrlBindingFactory factory = super.getUrlBindingFactory();
+        factory.addBinding( clazz, prototype );
         m_processed.add( clazz );
         return prototype.toString();
     }

Added: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageFormatter.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageFormatter.java?rev=814355&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageFormatter.java (added)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageFormatter.java Sun Sep 13 17:44:49 2009
@@ -0,0 +1,81 @@
+package org.apache.wiki.ui.stripes;
+
+import java.util.Locale;
+
+import net.sourceforge.stripes.format.Formatter;
+
+import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.ContentManager;
+import org.apache.wiki.content.WikiPath;
+
+/**
+ * Stripes Formatter class that formats a supplied WikiPage, with the result
+ * being the name of the page.
+ */
+public class WikiPageFormatter implements Formatter<WikiPage>
+{
+    /**
+     * {@inheritDoc}
+     * <p>
+     * This implementation produces a formatted String representing the WikiPage
+     * according to the following rules:
+     * </p>
+     * <ul>
+     * <li>if the WikiPage is null, returns the empty string</li>
+     * <li>if the WikiPage belongs to the default space, the path name without
+     * space is returned</li>
+     * <li>otherwise, the full path name, including the space, is returned</li>
+     * </ul>
+     */
+    public String format( WikiPage input )
+    {
+        WikiPath path = input.getPath();
+        if ( ContentManager.DEFAULT_SPACE.equals( path.getSpace() ) )
+        {
+            return path.getPath();
+        }
+        return path.toString();
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * This implementation does nothing.
+     * </p>
+     */
+    public void init()
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * This implementation does nothing; the page name is always used.
+     * </p>
+     */
+    public void setFormatPattern( String formatPattern )
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * This implementation does nothing; the page name is always used.
+     * </p>
+     */
+    public void setFormatType( String formatType )
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * This implementation does nothing, because the Locale has no effect on the
+     * output.
+     * </p>
+     */
+    public void setLocale( Locale locale )
+    {
+    }
+
+}

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/FileBasedActionResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/FileBasedActionResolverTest.java?rev=814355&r1=814354&r2=814355&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/FileBasedActionResolverTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/FileBasedActionResolverTest.java Sun Sep 13 17:44:49 2009
@@ -20,17 +20,14 @@
  */
 package org.apache.wiki.ui.stripes;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import net.sourceforge.stripes.action.ActionBean;
 import net.sourceforge.stripes.controller.DispatcherServlet;
 import net.sourceforge.stripes.controller.StripesFilter;
-import net.sourceforge.stripes.controller.UrlBindingFactory;
 import net.sourceforge.stripes.mock.MockRoundtrip;
 import net.sourceforge.stripes.mock.MockServletContext;
 
@@ -62,16 +59,7 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
-
-        // Flush the existing bindings; we need to do this because Stripes doesn't between launches
-        UrlBindingFactory factory = UrlBindingFactory.getInstance();
-        Collection<Class<? extends ActionBean>> beanClasses = factory.getPathMap().values();
-        for ( Class<? extends ActionBean> beanClass : beanClasses )
-        {
-            factory.removeBinding( beanClass );
-        }
-        
-}
+    }
     
     public void testViewActionBean() throws Exception
     {