Package org.zkoss.zk.ui.sys

Examples of org.zkoss.zk.ui.sys.DesktopCtrl


  private final Component mergeNext() {
    final AbstractComponent parent = (AbstractComponent)getParent();
    if (parent != null) {
      final AbstractComponent n = (AbstractComponent)getNextSibling();
      if (n instanceof HtmlNativeComponent) {
        final DesktopCtrl desktopCtrl = _page != null ?
          (DesktopCtrl)_page.getDesktop(): null;
         if (n.getFirstChild() == null) {
           //remove n
           final AbstractComponent n2 = (AbstractComponent)n.getNextSibling();
           parent.setNext(this, n2);
           parent.setPrev(n2, this);
           parent.incNChild(-1);

          final String s = ((HtmlNativeComponent)n).getFullContent();
           _postfix = _postfix != null ? _postfix + s: s;
          if (desktopCtrl != null)
            desktopCtrl.removeComponent(n, false); //ok but no need to recycle
          return this;
         }
         if (getFirstChild() == null) {
           //remove this
           final AbstractComponent p = (AbstractComponent)getPreviousSibling();
           parent.setNext(p, n);
           parent.setPrev(n, p);
           parent.incNChild(-1);

           final String s = getFullContent(),
             prefix = ((HtmlNativeComponent)n)._prefix;
           ((HtmlNativeComponent)n)._prefix = prefix != null ? s + prefix: s;
          if (desktopCtrl != null)
            desktopCtrl.removeComponent(this, false); //ok but no need to recycle
          return n;
         }
      }
    }
    return null;
View Full Code Here


            return null; //only one child-with-child is allowed
          childWithChild = (HtmlNativeComponent)child;
        }
      }

      final DesktopCtrl desktopCtrl = _page != null ?
        (DesktopCtrl)_page.getDesktop(): null;
      boolean bEpilog = false;
      for (child = getFirstChild(); child != null;
      child = child.getNextSibling()) {
        final HtmlNativeComponent nc = (HtmlNativeComponent)child;
        if (bEpilog) {
          _epilog += nc.getFullContent();
        } else if (child != childWithChild) {
          _prolog += nc.getPrologHalf();
          _epilog = nc.getEpilogHalf() + _epilog;
          bEpilog = true;
        } else { //childWithChild
          _prolog = nc.getFullContent() + _prolog;
        }
        if (desktopCtrl != null)
          desktopCtrl.removeComponent(nc, false); //ok but no need to recycle
      }
      if (childWithChild == null) {
        nChild(null, null, 0);
      } else {
        nChild(
View Full Code Here

    }

    //2b. remove pages. Note: we don't need to generate rm, becausee they
    //are included pages.
    if (_pgRemoved != null) {
      final DesktopCtrl dtctl = (DesktopCtrl)_exec.getDesktop();
      for (final Iterator it = _pgRemoved.iterator(); it.hasNext();)
        dtctl.removePage((Page)it.next());
    }

    //3. generate response for invalidated pages
    if (_pgInvalid != null) {
      for (final Iterator it = _pgInvalid.iterator(); it.hasNext();) {
View Full Code Here

      comp._page = _page;
      if (comp._parent == null)
        ((AbstractPage)_page).onReplaced(this, comp);
        //call onReplaced instead addRoot/removeRoot

      final DesktopCtrl desktopCtrl = (DesktopCtrl)_page.getDesktop();
      desktopCtrl.removeComponent(this, false);
      desktopCtrl.addComponent(comp);
      _page = null;
    }

    //add comp to the fellow map
    if (bFellow) {
View Full Code Here

   * @since 3.6.0
   */
  public static
  Page newPage(UiFactory uf, RequestInfo ri, PageDefinition pagedef,
  ServletResponse response, String path) {
    final DesktopCtrl desktopCtrl = (DesktopCtrl)ri.getDesktop();
    final Execution exec = ExecutionsCtrl.getCurrent();
    TemporaryExecution de = new TemporaryExecution(
      (ServletContext)ri.getWebApp().getNativeContext(),
      (HttpServletRequest)ri.getNativeRequest(),
      (HttpServletResponse)response, ri.getDesktop());
    desktopCtrl.setExecution(de);
    ExecutionsCtrl.setCurrent(de);
    try {
      return uf.newPage(ri, pagedef, path);
        //de won't be voided since no DesktopInit-like plugin
    } finally {
      ExecutionsCtrl.setCurrent(exec);
      desktopCtrl.setExecution(exec);
    }
  }
View Full Code Here

   * @since 3.6.0
   */
  public static
  Page newPage(UiFactory uf, RequestInfo ri, Richlet richlet,
  ServletResponse response, String path) {
    final DesktopCtrl desktopCtrl = (DesktopCtrl)ri.getDesktop();
    final Execution exec = ExecutionsCtrl.getCurrent();
    TemporaryExecution de = new TemporaryExecution(
      (ServletContext)ri.getWebApp().getNativeContext(),
      (HttpServletRequest)ri.getNativeRequest(),
      (HttpServletResponse)response, ri.getDesktop());
    desktopCtrl.setExecution(de);
    ExecutionsCtrl.setCurrent(de);
    try {
      return uf.newPage(ri, richlet, path);
        //de won't be voided since no DesktopInit-like plugin
    } finally {
      ExecutionsCtrl.setCurrent(exec);
      desktopCtrl.setExecution(exec);
    }
  }
View Full Code Here

    try {
      final WebApp wapp = sess.getWebApp();
      final WebAppCtrl wappc = (WebAppCtrl)wapp;
      final UiEngine uieng = wappc.getUiEngine();
      final Desktop desktop = wappc.getDesktopCache(sess).getDesktop(dtid);
      final DesktopCtrl desktopCtrl = (DesktopCtrl)desktop;

      final Execution oldexec = Executions.getCurrent();
      final Execution exec = new ExecutionImpl(
        _ctx, request, response, desktop, null);
      uieng.activate(exec);

      final Configuration config = wapp.getConfiguration();
      boolean err = false;
      try {
        config.invokeExecutionInits(exec, oldexec);
        desktopCtrl.invokeExecutionInits(exec, oldexec);

        media = desktopCtrl.getDownloadMedia(uuid, false);
        if (media != null) {
          download = true; //yes, it is for download
        } else {
          final Component comp = desktop.getComponentByUuid(uuid);
          final Object cc = ((ComponentCtrl)comp).getExtraCtrl();
          if (!(cc instanceof DynamicMedia))
            throw new ServletException(DynamicMedia.class+" must be implemented by getExtraCtrl() of "+comp);
          media = ((DynamicMedia)cc).getMedia(l >= 0 ? pi.substring(l): "");
          if (media == null) {
            response.sendError(response.SC_GONE, Messages.get(MZk.PAGE_NOT_FOUND, pi+" - "+comp));
            return;
          }
        }
      } catch (Throwable ex) {
        err = true;

        final List errs = new LinkedList();
        errs.add(ex);
        desktopCtrl.invokeExecutionCleanups(exec, oldexec, errs);
        config.invokeExecutionCleanups(exec, oldexec, errs);

        final StringBuffer errmsg = new StringBuffer(100);
        if (!errs.isEmpty()) {
          for (Iterator it = errs.iterator(); it.hasNext();) {
            final Throwable t = (Throwable)it.next();
            log.realCauseBriefly("Failed to load media, "+pi, t);
            errmsg.append('\n').append(Exceptions.getMessage(t));
          }
        }

        response.sendError(response.SC_GONE,
          Messages.get(MZk.PAGE_FAILED, new Object[] {pi, errmsg, ""}));
        return;
      } finally {
        if (!err) {
          desktopCtrl.invokeExecutionCleanups(exec, oldexec, null);
          config.invokeExecutionCleanups(exec, oldexec, null);
        }
        uieng.deactivate(exec);
      }
    } catch (ComponentNotFoundException ex) {
View Full Code Here

    sess.setAttribute(Attributes.GAE_FIX, new Integer(0)); //enforce GAE to write session
    ((SessionCtrl)sess).notifyClientRequest(keepAlive);

//    if (log.debugable()) log.debug("AU request: "+aureqs);
    final DesktopCtrl desktopCtrl = (DesktopCtrl)desktop;
    final Execution exec =
      new ExecutionImpl(_ctx, request, response, desktop, null);
    if (sid != null)
      ((ExecutionCtrl)exec).setRequestId(sid);
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.sys.DesktopCtrl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.