Revision: 816
          http://stripes.svn.sourceforge.net/stripes/?rev=816&view=rev
Author:   bengunter
Date:     2008-01-30 08:25:24 -0800 (Wed, 30 Jan 2008)

Log Message:
-----------
Fixed STS-493. s:link and s:url have a new attribute 
prependContext="true|false".

Modified Paths:
--------------
    trunk/stripes/resources/stripes.tld
    trunk/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java

Modified: trunk/stripes/resources/stripes.tld
===================================================================
--- trunk/stripes/resources/stripes.tld 2008-01-30 15:41:25 UTC (rev 815)
+++ trunk/stripes/resources/stripes.tld 2008-01-30 16:25:24 UTC (rev 816)
@@ -790,16 +790,23 @@
                 to the URL/href supplied).
             </description>
             
<name>event</name><required>false</required><rtexprvalue>true</rtexprvalue>
+        </attribute>
+        <attribute>
+            <description>
+                Indicates if the _sourcePage parameter should be appended to 
the URL. Default
+                value is false.
+            </description>
+            
<name>addSourcePage</name><required>false</required><rtexprvalue>true</rtexprvalue>
+        </attribute>
+        <attribute>
+            <description>
+                Indicates if the application context path should be included 
at the beginning of
+                the generated URL.
+            </description>
+            
<name>prependContext</name><required>false</required><rtexprvalue>true</rtexprvalue>
         </attribute>
         <attribute>
             <description>
-                Indicates if the _sourcePage parameter should be appended to 
the URL. Default
-                value is false.
-            </description>
-            
<name>addSourcePage</name><required>false</required><rtexprvalue>true</rtexprvalue>
-        </attribute>
-        <attribute>
-            <description>
                 The fully qualified name of an ActionBean class, or 
alternatively a Class instance
                 for an ActionBean class.  An alternative to the 'href' 
attribute, the 'beanclass'
                 attribute will generate an href appropriate for the ActionBean 
identified. Note
@@ -1840,7 +1847,8 @@
             Similar to the link tag except that the behaviour closely 
approximates the JSTL
             c:url tag. Generates a URL containing the necessary source-page 
and event
             parameters. If a 'var' attribute is specified, the generated URL 
will be written
-            to that variable, otherwise it will be written into the page. Like 
c:url the constructed url is not encoded.
+            to that variable, otherwise it will be written into the page. Like 
c:url the
+            constructed url is not encoded.
         ]]></description>
         <display-name>url</display-name>
         <name>url</name>
@@ -1887,6 +1895,13 @@
             </description>
             
<name>beanclass</name><required>false</required><rtexprvalue>true</rtexprvalue>
             <type>java.lang.Object</type>
+        </attribute>
+        <attribute>
+            <description>
+                Indicates if the application context path should be included 
at the beginning of
+                the generated URL.
+            </description>
+            
<name>prependContext</name><required>false</required><rtexprvalue>true</rtexprvalue>
         </attribute>
     </tag>
 

Modified: trunk/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java   
2008-01-30 15:41:25 UTC (rev 815)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java   
2008-01-30 16:25:24 UTC (rev 816)
@@ -38,6 +38,7 @@
     private Object beanclass;
     private String url;
     private boolean addSourcePage = false;
+    private boolean prependContext = true;
 
     /**
      * Gets the URL that is supplied by the user/developer on the page. This 
is the basis
@@ -115,6 +116,12 @@
      */
     public void setAddSourcePage(boolean addSourcePage) { this.addSourcePage = 
addSourcePage; }
 
+    /** Get the flag that indicates if the application context should be 
included in the URL. */
+    public boolean isPrependContext() { return prependContext; }
+
+    /** Set the flag that indicates if the application context should be 
included in the URL. */
+    public void setPrependContext(boolean prependContext) { 
this.prependContext = prependContext; }
+
     /**
      * Returns the base URL that should be used for building the link. This is 
derived from
      * the 'beanclass' attribute if it is set, else from the 'url' attribute.
@@ -170,9 +177,11 @@
 
         // Prepend the context path, but only if the user didn't already
         String url = builder.toString();
-        String contextPath = request.getContextPath();
-        if (!"/".equals(contextPath) && !url.startsWith(contextPath + "/")) {
-            url = contextPath + url;
+        if (prependContext) {
+            String contextPath = request.getContextPath();
+            if (!"/".equals(contextPath) && !url.startsWith(contextPath + 
"/")) {
+                url = contextPath + url;
+            }
         }
 
         return response.encodeURL(url);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to