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

sendRedirect from DesktopInit omits contextPath

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 8.5.1
    • Fix Version/s: 8.5.2
    • Component/s: ZK Loader
    • Security Level: Jimmy
    • Labels:

      Description

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

        Activity

        Hide
        JamesChu JamesChu added a comment -

        Fixed since 2018/04/24

        Show
        JamesChu JamesChu added a comment - Fixed since 2018/04/24

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              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