
|
If you were logged in you would be able to see more operations.
|
|
|
Click
Created: 09/Oct/08 04:47 AM
Updated: 17/Oct/08 03:56 PM
|
|
| Component/s: |
None
|
| Affects Version/s: |
1.5 RC2
|
| Fix Version/s: |
1.5 RC3
|
|
|
Hi, since the setRedirect logic was moved to the Page control...
we must validate to guarantee that the "contextPath" will not be appended to the url twice.
if you call setRedirect() two times (i know it´s strange but it´s possible), it will duplicate the contextPath...
This is how I fixed this for my app:
/**
* @see net.sf.click.Page#setRedirect(java.lang.String)
*/
public void setRedirect(String location) {
if (location != null) {
if (location.charAt(0) == '/') {
Context context = getContext();
String contextPath = context.getRequest().getContextPath();
if(!location.startsWith(contextPath)){
location = contextPath + location;
}
}
}
redirect = location;
}
|
|
Description
|
Hi, since the setRedirect logic was moved to the Page control...
we must validate to guarantee that the "contextPath" will not be appended to the url twice.
if you call setRedirect() two times (i know it´s strange but it´s possible), it will duplicate the contextPath...
This is how I fixed this for my app:
/**
* @see net.sf.click.Page#setRedirect(java.lang.String)
*/
public void setRedirect(String location) {
if (location != null) {
if (location.charAt(0) == '/') {
Context context = getContext();
String contextPath = context.getRequest().getContextPath();
if(!location.startsWith(contextPath)){
location = contextPath + location;
}
}
}
redirect = location;
} |
Show » |
|
|
Because invoking setRedirect multiple times with a location seems to work:
public void onInit() {
setRedirect("/test.htm");
setRedirect("/test.htm");
}
This produced '/mycontext/test.htm'