Steps to Reproduce
configure the DesktopInit below
public class RedirectDesktopInit implements DesktopInit { @Override public void init(Desktop desktop, Object request) throws Exception { desktop.getExecution().sendRedirect("/test"); } }
Current Result
when redirecting the contextPath is not prepended to the redirect uri
Expected Result
should work consistently as when called from other listeners
both cases below prepend the contextPath as expected
public class RedirectInitiator implements Initiator { @Override public void doInit(Page page, Map<String, Object> args) throws Exception { page.getDesktop().getExecution().sendRedirect("/test"); } }
public class RedirectExecutionInit implements ExecutionInit { @Override public void init(Execution exec, Execution parent) throws Exception { exec.sendRedirect("/test"); } }
Debug Info
When calling from a DesktopInit listener the execution object is of type org.zkoss.zk.ui.http.TemporaryExecution which behaves differently
Workaround
when redirecting from a DesktopInit enode the url manually:
Execution execution = desktop.getExecution();
execution.sendRedirect(execution.encodeURL("/test"));