Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.Page


  private void checkPageRemoved(Set removed) {
    //1. scan once
    final Desktop desktop = _exec.getDesktop();
    Set pages = null;
    for (Iterator it = desktop.getPages().iterator(); it.hasNext();) {
      final Page page = (Page)it.next();
      final Component owner = ((PageCtrl)page).getOwner();
      if (owner != null) { //included
        final Page ownerPage = owner.getPage();
        if (ownerPage == null //detached
        || (_pgInvalid != null && _pgInvalid.contains(ownerPage))
        || isAncestor(_invalidated, owner, true)
        || isAncestor(_attached, owner, true)
        || isAncestor(removed, owner, true)) {
          addPageRemoved(page);
        } else {
          if (pages == null) pages = new LinkedHashSet();
          pages.add(page);
        }
      }
    }
    if (_pgRemoved == null || pages == null) return;
      //done if no page is removed or no more included page

    //2. if a page is ever removed, it might cause chain effect
    //so we have to loop until nothing changed
    boolean pgRemovedFound;
    do {
      pgRemovedFound = false;
      for (Iterator it = pages.iterator(); it.hasNext();) {
        final Page page = (Page)it.next();
        final Component owner = ((PageCtrl)page).getOwner();
        if (_pgRemoved.contains(owner.getPage())) {
          it.remove();
          addPageRemoved(page);
          pgRemovedFound = true;
View Full Code Here


  }
  /** Clears components if it belongs to invalidated or removed page. */
  private void clearInInvalidPage(Collection coll) {
    for (Iterator it = coll.iterator(); it.hasNext();) {
      final Component comp = (Component)it.next();
      final Page page = comp.getPage();
      if (page != null
      && ((_pgRemoved != null && _pgRemoved.contains(page))
      ||  (_pgInvalid != null && _pgInvalid.contains(page))))
        it.remove();
    }
View Full Code Here

    }

    //3. generate response for invalidated pages
    if (_pgInvalid != null) {
      for (final Iterator it = _pgInvalid.iterator(); it.hasNext();) {
        final Page page = (Page)it.next();
        responses.add(new AuOuter(page, redraw(page)));
      }
    }

/*    if (log.finerable())
      log.finer("After removing redudant: invalidated: "+_invalidated
      +"\nAttached: "+_attached+"\nSmartUpd:"+_smartUpdated);
*/
    //4. process special interfaces

    //5. generate replace for invalidated
    for (Iterator it = _invalidated.iterator(); it.hasNext();) {
      final Component comp = (Component)it.next();
      responses.add(new AuOuter(comp, redraw(comp)));
    }

    _ending = true; //no more addSmartUpdate...

    //6. add attached components (including setParent)
    //Due to cyclic references, we have to process all siblings
    //at the same time
    final List desktops = new LinkedList();
    final Component[] attached = (Component[])
      _attached.toArray(new Component[_attached.size()]);
    for (int j = 0; j < attached.length; ++j) {
      final Component comp = attached[j];
      //Note: attached comp might change from another page to
      //the one being created. In this case, no need to add
      if (comp != null) {
        final Page page = comp.getPage();
        if (page != null && _exec.isAsyncUpdate(page)) {
          final Component parent = comp.getParent();
          final Set newsibs = new LinkedHashSet(32);
          newsibs.add(comp);
          desktops.add(newsibs);
View Full Code Here

  private Set doMoved(List responses) {
    //Remove components that have to removed from the client
    final Set removed = new LinkedHashSet();
    for (Iterator it = _moved.iterator(); it.hasNext();) {
      final Component comp = (Component)it.next();
      final Page page = comp.getPage();
      if (page == null) {
        removed.add(comp);

        if (_responses != null) _responses.remove(comp);
        _invalidated.remove(comp);
View Full Code Here

   */
  private static
  void addResponsesForCreatedPerSiblings(List responses, Set newsibs,
  Map croppingInfos) throws IOException {
    final Component parent;
    final Page page;
    {
      final Component comp = (Component)newsibs.iterator().next();
      parent = comp.getParent();
      page = comp.getPage();
    }
    Collection sibs;
    if (parent != null) {
      sibs = getAvailableAtClient(parent, croppingInfos);
      if (sibs == null) //no cropping
        sibs = parent.getChildren();
      else if (sibs.size() > 1 && !(sibs instanceof LinkedHashSet)) {
//        log.warning("Use LinkedHashSet instead of "+sibs.getClass());
        final Set s = new LinkedHashSet(sibs.size() * 2);
        for (Iterator it = parent.getChildren().iterator(); it.hasNext();) {
          final Object o = it.next();
          if (sibs.remove(o)) {
            s.add(o);
            if (sibs.isEmpty())
              break;
          }
        }
        sibs = s;
      }
    } else {
      sibs = page.getRoots();
    }
//    if (D.ON && log.finerable()) log.finer("All sibs: "+sibs+" newsibs: "+newsibs);

    /* Algorithm:
  1. Locate a sibling, say <a>, that already exists.
View Full Code Here

      ((SessionCtrl)sess).notifyClientRequest(true);

      final UiFactory uf = wappc.getUiFactory();
      final Richlet richlet = new StandaloneRichlet(comp);

      final Page page = WebManager.newPage(uf, ri, richlet, response, path);
      exec = new ExecutionImpl(ctx, request, response, desktop, page);
      exec.setAttribute(Attributes.PAGE_REDRAW_CONTROL, "page");
      exec.setAttribute(Attributes.PAGE_RENDERER, new PageRenderer(exec));

      wappc.getUiEngine().execNewPage(exec, richlet, page, out);
View Full Code Here

    } else if (beanid.startsWith(".")) { //a relative component Path: ./ or ../
      bean = Path.getComponent(comp.getSpaceOwner(), beanid);
    } else {
      //VariableResolver would need such "self" information when doing
      //variable resolving
      final Page page = comp.getPage();
      if (page != null) { //Bug #2823591, try to "load" into a detached(no page) component and NPE
        //bug #2932475, NoSuchMethodException in DataBinder (SpaceOwner-Mixup)
        bean = Components.getImplicit(comp, beanid);
        //bug #2945974
        //dirty patch
        if ("param".equals(beanid) && bean != null) {
          bean = new HashMap((Map) bean);
        }
        if (bean == null) {
          bean = page.getZScriptVariable(comp, beanid);
          if (bean == null) {
            final Object self = page.getAttribute("self");
            try {
              page.setAttribute("self", comp);
              bean = comp.getAttributeOrFellow(beanid, true);
              if (bean == null)
                bean = page.getXelVariable(null, null, beanid, true);
            } finally {
              if (self == null) {
                page.removeAttribute("self");
              } else {
                page.setAttribute("self", self);
              }
            }
          }
        }
      }
View Full Code Here

  private Comparator toComparator(String clsnm)
  throws ClassNotFoundException, InstantiationException,
  IllegalAccessException {
    if (clsnm == null || clsnm.length() == 0) return null;

    final Page page = getPage();
    final Class cls = page != null ?
      page.getZScriptClass(clsnm): Classes.forNameByThread(clsnm);
    if (cls == null)
      throw new ClassNotFoundException(clsnm);
    if (!Comparator.class.isAssignableFrom(cls))
      throw new UiException("Comparator must be implemented: "+clsnm);
    return (Comparator)cls.newInstance();
View Full Code Here

    if (ComponentsCtrl.getEventMethod(comp.getClass(), evtnm) != null
    || comp.isListenerAvailable(evtnm, asap))
      return true;

    if (!asap) {
      final Page page = comp.getPage();
      return page != null && page.isListenerAvailable(evtnm);
    }
    return false;
  }
View Full Code Here

    final Thread thd = (Thread)Thread.currentThread();
    if (!(thd instanceof EventProcessingThread)) {
      if (!desktop.getWebApp().getConfiguration().isEventThreadEnabled()) {
        final ExecutionCtrl execCtrl = (ExecutionCtrl)exec;
        final Page page = execCtrl.getCurrentPage();
        final EventProcessor proc =
          new EventProcessor(desktop, comp, event);
        proc.setup();
        try {
          proc.process();
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.Page

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.