コード例 #1
0
ファイル: ExecutionImpl.java プロジェクト: kachhalimbu/zk
 public void include(Writer out, String page, Map<String, ?> params, int mode) throws IOException {
   try {
     if (!dispatch(out, page, params, mode, true))
       Servlets.include(
           _ctx, _request, HttpBufferedResponse.getInstance(_response, out), page, params, mode);
   } catch (ServletException ex) {
     throw new UiException(ex);
   }
 }
コード例 #2
0
ファイル: ExecutionImpl.java プロジェクト: kachhalimbu/zk
  public void forward(Writer out, String page, Map<String, ?> params, int mode) throws IOException {
    final Visualizer uv = getVisualizer();
    // uv is null if it is called in DesktopInit (with TemporaryExecution)
    if (uv != null && uv.isEverAsyncUpdate())
      throw new IllegalStateException("Use sendRedirect instead when processing user's request");

    setVoided(true);

    try {
      if (!dispatch(out, page, params, mode, false))
        Servlets.forward(
            _ctx, _request, HttpBufferedResponse.getInstance(_response, out), page, params, mode);
    } catch (ServletException ex) {
      throw new UiException(ex);
    }
  }
コード例 #3
0
ファイル: ExecutionImpl.java プロジェクト: kachhalimbu/zk
  private boolean dispatch(Writer out, String page, Map params, int mode, boolean include)
      throws IOException, ServletException {
    // FUTURE: handle if ~./, PASS_THRU_ATTR and with query string
    // In other words, we convert query string to params if
    // PASS_THRU_ATTR and ~./ (to have a better performance)
    if ((mode != PASS_THRU_ATTR && params != null)
        || !page.startsWith("~./")
        || page.indexOf('?') >= 0) return false;

    // Bug 1801028: We cannot invoke ZumlExtendlet directly
    // The real reason is unknown yet -- it could be due to
    // the re-creation of ExecutionImpl
    // However, the performance is not a major issue, so just skip
    final ClassWebResource cwr = WebManager.getWebManager(_ctx).getClassWebResource();
    if (!isDirectInclude(cwr, page)) return false;

    Object old = null;
    if (mode == PASS_THRU_ATTR) {
      old = _request.getAttribute(Attributes.ARG);
      if (params != null) _request.setAttribute(Attributes.ARG, params);
      // If params=null, use the 'inherited' one (same as Servlets.include)
    }

    final String attrnm =
        include ? "org.zkoss.web.servlet.include" : "org.zkoss.web.servlet.forward";
    _request.setAttribute(attrnm, Boolean.TRUE);
    // so Servlets.isIncluded returns correctly
    try {
      cwr.service(_request, HttpBufferedResponse.getInstance(_response, out), page.substring(2));
    } finally {
      _request.removeAttribute(attrnm);
      if (mode == PASS_THRU_ATTR) _request.setAttribute(Attributes.ARG, old);
    }

    return true;
  }