You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "smallufo (JIRA)" <ji...@apache.org> on 2008/05/11 07:21:55 UTC
[jira] Commented: (WICKET-1599) RequestUtils.toAbsolutePath()'s bug
[ https://issues.apache.org/jira/browse/WICKET-1599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595881#action_12595881 ]
smallufo commented on WICKET-1599:
----------------------------------
Sometimes , absUrl become "http://www.foobar.com/foobar/SecondPage/index/1"
The preceding "http://www.foobar.com/" is redundant ! (Because it lacks of contextPath : "app/" )
After pre-adding "http://" + req.getServerName() + contextPath + "/" , the whole URL becomes :
http://www.foobar.com/app/http://www.foobar.com/foobar/SecondPage/index/1
To get rid of the two problems , I have to add the post-processing code after getting absUrl :
String contextPath = ((WebRequestCycle)rc).getWebRequest().getServletPath();
HttpServletRequest hreq = ((WebRequestCycle)rc).getWebRequest().getHttpServletRequest();
StringBuffer sb = new StringBuffer();
sb.append("http://");
sb.append(hreq.getServerName());
sb.append(contextPath);
String absUrl = RequestUtils.toAbsolutePath(rc.urlFor(SecondPage.class , pps).toString());
if (absUrl.startsWith("http://"+hreq.getServerName()+"/"))
absUrl = absUrl.substring(("http://"+hreq.getServerName()+"/").length());
else if (absUrl.startsWith("http://"))
absUrl = absUrl.substring(7);
sb.append(absUrl);
After this , I can get correct absUrl...
> RequestUtils.toAbsolutePath()'s bug
> -----------------------------------
>
> Key: WICKET-1599
> URL: https://issues.apache.org/jira/browse/WICKET-1599
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.3.3
> Environment: Firefox
> Reporter: smallufo
> Assignee: Alastair Maw
>
> Suppose the following code in a bookmarkable page , say "FirstPage" :
> When user pushes an AJAX button , the page builds a bookmarkable link :
> Map<String , Object> parameterMap = new HashMap<String , Object>();
> parameterMap.put("index" , myObj.getIndex());
> PageParameters pps = new PageParameters(parameterMap);
> String absUrl = RequestUtils.toAbsolutePath(getRequestCycle().urlFor(SecondPage.class , pps).toString());
> If the user navigates properly (by clicking links to the FirstPage) ,
> the absUrl is correct : foobar/SecondPage/index/1/
> after pre-adding "http://" + req.getServerName() + contextPath + "/" , I can correctly build the (bookmarkable) link like this :
> http://www.foobar.com/app/foobar/SecondPage/index/1
> BUT , if the user directly links to the FirstPage(copy / paste the FirstPage's url in the browser's url bar) ,
> or clicks the SecondPage's link and back (by browser) , and pushes the AJAX button again...
> SOMETIMES , absUrl becomes :
> http://foobar/SecondPage/index/1/ , the preceding "http://" is redundant !!!
> And , my bookmarkable link becomes : http://www.foobar.com/app/http://foobar/SecondPage/index/1
> I can not successfully re-produce this error every time. but sometimes it just occurs .
> It seems it is a bug...
> PS : I know how to build a BookmarkablePageLink in the wicket way , But I have to do this for a special purpose.....(parsing an article and adding links to some keywords)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.