struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jhol...@apache.org
Subject svn commit: r565422 - in /struts/struts2/branches/STRUTS_2_0_X/core/src: main/java/org/apache/struts2/components/ main/java/org/apache/struts2/views/jsp/ site/resources/tags/ test/java/org/apache/struts2/views/jsp/
Date Mon, 13 Aug 2007 17:09:17 GMT
Author: jholmes
Date: Mon Aug 13 10:09:16 2007
New Revision: 565422

URL: http://svn.apache.org/viewvc?view=rev&rev=565422
Log:
WW-1948 s:url tag does not provide forceAddSchemeHostAndPort parameter

Modified:
    struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/URL.java
    struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/jsp/URLTag.java
    struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html
    struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java

Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/URL.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/URL.java?view=diff&rev=565422&r1=565421&r2=565422
==============================================================================
--- struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/URL.java
(original)
+++ struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/URL.java
Mon Aug 13 10:09:16 2007
@@ -88,6 +88,7 @@
  *      <li>portletMode (String) - The resulting portlet mode.</li>
  *      <li>windowState (String) - The resulting portlet window state.</li>
  *      <li>portletUrlType (String) - Specifies if this should be a portlet render
or action URL.</li>
+ *      <li>forceAddSchemeHostAndPort (Boolean) - Specifies whether to force the addition
of scheme, host and port or not.</li>
  * </ul>
  *
  * <!-- END SNIPPET: params -->
@@ -150,6 +151,7 @@
     protected String windowState;
     protected String portletUrlType;
     protected String anchor;
+    protected boolean forceAddSchemeHostAndPort;
     protected String urlIncludeParams;
     protected ExtraParameterProvider extraParameterProvider;
 
@@ -247,14 +249,14 @@
 
         String result;
         if (value == null && action != null) {
-            if(Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest())
{
+            if (Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest())
{
                 result = PortletUrlHelper.buildUrl(action, namespace, parameters, portletUrlType,
portletMode, windowState);
             }
             else {
-                result = determineActionURL(action, namespace, method, req, res, parameters,
scheme, includeContext, encode, false, escapeAmp);
+                result = determineActionURL(action, namespace, method, req, res, parameters,
scheme, includeContext, encode, forceAddSchemeHostAndPort, escapeAmp);
             }
         } else {
-            if(Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest())
{
+            if (Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest())
{
                 result = PortletUrlHelper.buildResourceUrl(value, parameters);
             }
             else {
@@ -265,7 +267,7 @@
                 if (_value != null && _value.indexOf("?") > 0) {
                     _value = _value.substring(0, _value.indexOf("?"));
                 }
-                result = UrlHelper.buildUrl(_value, req, res, parameters, scheme, includeContext,
encode, false, escapeAmp);
+                result = UrlHelper.buildUrl(_value, req, res, parameters, scheme, includeContext,
encode, forceAddSchemeHostAndPort, escapeAmp);
             }
         }
         if ( anchor != null && anchor.length() > 0 ) {
@@ -352,6 +354,11 @@
     @StrutsTagAttribute(description="Specifies whether to escape ampersand (&amp;) to
(&amp;amp;) or not", type="Boolean", defaultValue="true")
     public void setEscapeAmp(boolean escapeAmp) {
         this.escapeAmp = escapeAmp;
+    }
+
+    @StrutsTagAttribute(description="Specifies whether to force the addition of scheme, host
and port or not", type="Boolean", defaultValue="false")
+    public void setForceAddSchemeHostAndPort(boolean forceAddSchemeHostAndPort) {
+        this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
     }
 
 

Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/jsp/URLTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/jsp/URLTag.java?view=diff&rev=565422&r1=565421&r2=565422
==============================================================================
--- struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/jsp/URLTag.java
(original)
+++ struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/jsp/URLTag.java
Mon Aug 13 10:09:16 2007
@@ -49,6 +49,7 @@
     protected String windowState;
     protected String portletUrlType;
     protected String anchor;
+    protected String forceAddSchemeHostAndPort;
 
     public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse
res) {
         return new URL(stack, req, res);
@@ -78,6 +79,9 @@
         if (escapeAmp != null) {
             url.setEscapeAmp(Boolean.valueOf(escapeAmp).booleanValue());
         }
+	if (forceAddSchemeHostAndPort != null) {
+            url.setForceAddSchemeHostAndPort(Boolean.valueOf(forceAddSchemeHostAndPort).booleanValue());
+        }
     }
 
     public void setEncode(String encode) {
@@ -115,17 +119,24 @@
     public void setValue(String value) {
         this.value = value;
     }
+
     public void setPortletMode(String portletMode) {
         this.portletMode = portletMode;
     }
+
     public void setPortletUrlType(String portletUrlType) {
         this.portletUrlType = portletUrlType;
     }
+
     public void setWindowState(String windowState) {
         this.windowState = windowState;
     }
 
     public void setAnchor(String anchor) {
         this.anchor = anchor;
+    }
+
+    public void setForceAddSchemeHostAndPort(String forceAddSchemeHostAndPort) {
+        this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
     }
 }

Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html?view=diff&rev=565422&r1=565421&r2=565422
==============================================================================
--- struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html (original)
+++ struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html Mon Aug 13
10:09:16 2007
@@ -60,6 +60,14 @@
 					<td align="left" valign="top">Specifies whether to escape ampersand (&amp;)
to (&amp;amp;) or not</td>
 				</tr>
 				<tr>
+					<td align="left" valign="top">forceAddSchemeHostAndPort</td>
+					<td align="left" valign="top">false</td>
+					<td align="left" valign="top">false</td>
+					<td align="left" valign="top">false</td>
+					<td align="left" valign="top">Boolean</td>
+					<td align="left" valign="top">Specifies whether to force the addition of scheme,
host and port or not</td>
+				</tr>
+				<tr>
 					<td align="left" valign="top">id</td>
 					<td align="left" valign="top">false</td>
 					<td align="left" valign="top"></td>

Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java?view=diff&rev=565422&r1=565421&r2=565422
==============================================================================
--- struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java
(original)
+++ struts/struts2/branches/STRUTS_2_0_X/core/src/test/java/org/apache/struts2/views/jsp/URLTagTest.java
Mon Aug 13 10:09:16 2007
@@ -462,6 +462,15 @@
         assertEquals("/myapp/company.action", writer.toString());
     }
 
+    public void testForceAddSchemeHostAndPort() throws Exception {
+        tag.setForceAddSchemeHostAndPort("true");
+        tag.setAction("company");
+        tag.doStartTag();
+        tag.doEndTag();
+
+        assertEquals("http://localhost/company.action", writer.toString());
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
 



Mime
View raw message