struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rainer Hermanns (JIRA)" <j...@apache.org>
Subject [jira] Commented: (WW-1537) URL tag: webapp root repeats when path saved to local variable
Date Tue, 05 Dec 2006 19:59:57 GMT
    [ http://issues.apache.org/struts/browse/WW-1537?page=comments#action_38986 ] 
            
Rainer Hermanns commented on WW-1537:
-------------------------------------

Here is a patch proposal:
o reverted the call to buildUrl for the href attribute
o adding an additional attribute for ajaxHref containg the call to buildUrl
o changing the ajax templates to use the new attribute

o changed UrlHelper to check for an already added context path
(This last change needs some more thinking):

Problem: 
something like "/showcase/showcase/action.action" would not work, even if it would be intended?
 

Index: core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java
===================================================================
--- core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java	(revision
482733)
+++ core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java	(working
copy)
@@ -48,8 +48,10 @@
     public void evaluateExtraParams() {
         super.evaluateExtraParams();
 
-        if (href != null)
-            addParameter("href", UrlHelper.buildUrl(findString(href), request, response,
null));
+        if (href != null) {
+            addParameter("href", findString(href));
+            addParameter("ajaxHref", UrlHelper.buildUrl(findString(href), request, response,
null));
+        }
         if (errorText != null)
             addParameter("errorText", findString(errorText));
         if (loadingText != null)
Index: core/src/main/java/org/apache/struts2/views/util/UrlHelper.java
===================================================================
--- core/src/main/java/org/apache/struts2/views/util/UrlHelper.java	(revision 482733)
+++ core/src/main/java/org/apache/struts2/views/util/UrlHelper.java	(working copy)
@@ -129,7 +129,7 @@
             // Add path to absolute links
             if (action.startsWith("/") && includeContext) {
                 String contextPath = request.getContextPath();
-                if (!contextPath.equals("/")) {
+                if (!contextPath.equals("/") && !action.startsWith('/' + contextPath
+ '/')) {
                     link.append(contextPath);
                 }
             } else if (changedScheme) {
Index: core/src/main/resources/template/ajax/tab.ftl
===================================================================
--- core/src/main/resources/template/ajax/tab.ftl	(revision 482733)
+++ core/src/main/resources/template/ajax/tab.ftl	(working copy)
@@ -2,9 +2,9 @@
   <#if parameters.title?if_exists != "">
     label="${parameters.title?html}"<#rt/>
   </#if>
-  <#if parameters.href?if_exists != "">
+  <#if parameters.ajaxHref?if_exists != "">
     dojoType="LinkPane" <#rt/>
-    href="${parameters.href}"<#rt/>
+    href="${parameters.ajaxHref}"<#rt/>
     <#else>
     dojoType="ContentPane"<#rt/>
   </#if>
Index: core/src/main/resources/template/ajax/ajax-common.ftl
===================================================================
--- core/src/main/resources/template/ajax/ajax-common.ftl	(revision 482733)
+++ core/src/main/resources/template/ajax/ajax-common.ftl	(working copy)
@@ -25,8 +25,8 @@
   <#if parameters.name?if_exists != "">
   	name="${parameters.name?html}"<#rt/>
   </#if>
-  <#if parameters.href?if_exists != "">
-  	href="${parameters.href}"<#rt/>
+  <#if parameters.ajaxHref?if_exists != "">
+  	href="${parameters.ajaxHref}"<#rt/>
   </#if>
   <#if parameters.loadingText?if_exists != "">
     loadingText="${parameters.loadingText?html}"<#rt/>


> URL tag: webapp root repeats when path saved to local variable
> --------------------------------------------------------------
>
>                 Key: WW-1537
>                 URL: http://issues.apache.org/struts/browse/WW-1537
>             Project: Struts 2
>          Issue Type: Bug
>            Reporter: Ted Husted
>         Assigned To: Rainer Hermanns
>            Priority: Blocker
>
> Markup like
> <s:url id="url" action="showActionTagDemo" namespace="/tags/non-ui/actionTag"/><s:a
href="%{url}">Action
> </s:a>
> should render an URI like 
> * http://localhost:8080//struts2-showcase/tags/non-ui/
> but instead renders 
> * http://localhost:8080/struts2-showcase/struts2-showcase/tags/non-ui/
> Meanwhile 
> * <a href="<s:url id="url" action="showActionTagDemo" namespace="/tags/non-ui/actionTag"/>">Action
Tag</a>
> renders correctly, the difference being one uses a local variable. 
> Similarly, 
> * <s:url id="url" value="/tags/non-ui/" /><s:a href="%{url}">Non UI Tags
Examples</s:a>
> also hiccups and renders the web application root twice. 
> By contrast 
> * <s:url id="url" value="date.jsp" /><s:a href="%{url}">Date Tag</s:a>
> which doesn't inlcude a path, renders just fine, 
> * http://localhost:8080/struts2-showcase-2.0.2/tags/non-ui/date.jsp

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message