Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3894

sendRedirect from DesktopInit omits contextPath

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.5.2
    • 8.5.1
    • ZK Loader
    • Security Level: Jimmy

      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"));
      

            CharlesQiu CharlesQiu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 4 hours Remaining Estimate - 4 hours
                4h
                Logged:
                Time Spent - 4 hours Remaining Estimate - 4 hours
                4h