/** Invalidates the whole page. */ public void addInvalidate(Page page) { if (_recovering || _disabled || page == null || page instanceof VolatilePage || !_exec.isAsyncUpdate(page)) return; //nothing to do //relative fix for BUG ZK-1464 if (_ending && _pgRemoved != null && _pgRemoved.contains(page)) return; if (_pgInvalid == null) _pgInvalid = new LinkedHashSet<Page>(4); _pgInvalid.add(page); }
public boolean isAsyncUpdate(Page page) { return exec().isAsyncUpdate(page); }
private final boolean isAsyncUpdate() { final Execution exec = Executions.getCurrent(); return exec != null && exec.isAsyncUpdate(_page); }
/** Returns if this component needs to be redrawn. * <p>Note: * <ol> * <li>It always returns true if the current execution is not an * asynchronous update.</li> * <li>If its parent is invalidated, this component will be redrawn * too, but this method returns false since {@link #addInvalidate(Compnent)} * was not called against this component.</li> * </ol> * @since 3.0.5 */ public boolean isInvalidated(Component comp) { return !_exec.isAsyncUpdate(comp.getPage()) || _invalidated.contains(comp) || _attached.contains(comp) || _moved.contains(comp) || _detached.containsKey(comp); //No need to check page, recovering... since it won't be //part of _invalidated if so. }
/** Returns the response map for the specified attribute, or null if * nothing to do. */ private Map<String, TimedValue> getAttrRespMap(Component comp) { final Page page = comp.getPage(); if (_recovering || _disabled || page == null || page instanceof VolatilePage || !_exec.isAsyncUpdate(page) || _invalidated.contains(comp) || isCUDisabled(comp)) return null; //nothing to do if (_ending) throw new IllegalStateException("UI can't be modified in the rendering phase"); checkDesktop(comp); Map<String, TimedValue> respmap = _smartUpdated.get(comp); if (respmap == null) _smartUpdated.put(comp, respmap = new HashMap<String, TimedValue>()); return respmap; }
|| (newpg == null && (oldpg instanceof VolatilePage || !_exec.isAsyncUpdate(oldpg))) //detach from loading pg || (oldpg == null && (newpg instanceof VolatilePage || !_exec.isAsyncUpdate(newpg))) //attach to loading pg || isCUDisabled(comp) || (oldparent != null && isCUDisabled(oldparent))) return; //to avoid redundant AuRemove
/** Called before changing the component's UUID. * @since 5.0.3 */ public void addUuidChanged(Component comp) { //Algorithm of handling UUID change: //1. If it belongs a new page, nothing to do (since there is no client widget) //2. If not, it generates AuUuid of all modified UUID before generating //any other responses such that client's UUID will be corrected first if (_exec.isAsyncUpdate(comp.getPage()) //only if not belong to a new page && (_idChgd == null || !_idChgd.containsKey(comp)) && !isCUDisabled(comp)) { if (_idChgd == null) _idChgd = new LinkedHashMap<Component, String>(23); _idChgd.put(comp, comp.getUuid()); } }
/** Adds an invalidated component. Once invalidated, all invocations * to {@link #addSmartUpdate} are ignored in this execution. */ public void addInvalidate(Component comp) { final Page page = comp.getPage(); if (_recovering || _disabled || page == null || page instanceof VolatilePage || !_exec.isAsyncUpdate(page) || isCUDisabled(comp)) return; //nothing to do //relative fix BUG ZK-1464 if (_ending && _pgRemoved != null && _pgRemoved.contains(page)) return; if (_ending) throw new IllegalStateException("UI can't be modified in the rendering phase"); checkDesktop(comp); if (_invalidated.add(comp)) _smartUpdated.remove(comp); }
public void invalidate() { final Execution exec = Executions.getCurrent(); if (exec != null && exec.isAsyncUpdate(getPage())) throw new UnsupportedOperationException("body.invalidate() not allowed"); super.invalidate(); }
public void invalidate() { final Execution exec = Executions.getCurrent(); if (exec != null && exec.isAsyncUpdate(getPage())) throw new UnsupportedOperationException("html.invalidate() not allowed"); super.invalidate(); }
if (_exec.isAsyncUpdate(page)) responses.add(new AuRemove(uuid(comp)));
/** Crop attached and moved. */ private void crop(Set coll, Map<Component, Set<? extends Component>> croppingInfos, boolean bResponse) { for (Iterator it = coll.iterator(); it.hasNext();) { final Object o = it.next(); if (!(o instanceof Component)) continue; final Component comp = (Component) o; final Page page = comp.getPage(); if (page == null || !_exec.isAsyncUpdate(page)) { if (!bResponse) it.remove(); //just in case continue; } for (Component p, c = comp; (p = c.getParent()) != null; c = p) { final Set<? extends Component> avail = getAvailableAtClient(p, croppingInfos); if (avail != null) { if (!avail.contains(c)) { it.remove(); break; } p = ((Cropper) ((ComponentCtrl) p).getExtraCtrl()).getCropOwner(); if (p == null) break; } } } }
public void setTitle(String title) { if (title == null) title = ""; if (!_title.equals(title)) { _title = title; if (_desktop != null) { final Execution exec = getExecution(); if (_title.length() > 0) { _title = (String) exec.evaluate(this, _title, String.class); if (_title == null) _title = ""; } if (exec.isAsyncUpdate(this)) getUiEngine().addResponse(new AuSetTitle(_title)); } } }
/** Returns the first line to be generated to the output, * or null if no special first line. */ public static final String outFirstLine(Execution exec, Page page) { if (exec.getAttribute(FIRST_LINE_GENED) == null && !exec.isAsyncUpdate(null)) { exec.setAttribute(FIRST_LINE_GENED, Boolean.TRUE); return trimAndLF(((PageCtrl) page).getFirstLine()); } return ""; }
public void render(Page page, Writer out) throws IOException { final Execution exec = Executions.getCurrent(); final String ctl = ExecutionsCtrl.getPageRedrawControl(exec); boolean au = exec.isAsyncUpdate(null); if (!au && (page.isComplete() || "complete".equals(ctl))) { renderComplete(exec, page, out); return; } boolean pageOnly = au; if (!pageOnly) pageOnly = (exec.isIncluded() || "page".equals(ctl)) && !"desktop".equals(ctl); if (pageOnly) renderPage(exec, page, out, au); else renderDesktop(exec, page, out); }
public void render(Page page, Writer out) throws IOException { final Execution exec = Executions.getCurrent(); final String ctl = ExecutionsCtrl.getPageRedrawControl(exec); boolean au = exec.isAsyncUpdate(null); if (!au && (page.isComplete() || "complete".equals(ctl))) { renderComplete(exec, page, out); return; } boolean pageOnly = au; if (!pageOnly) pageOnly = (exec.isIncluded() || "page".equals(ctl)) && !"desktop".equals(ctl); if (pageOnly) renderPage(exec, page, out, au); else { exec.setAttribute(Attributes.PAGE_REDRAW_CONTROL, "complete"); renderComplete(exec, page, out); } }
/** Generates the unavailable message in HTML tags, if any. * @param exec the execution (never null) */ public static String outUnavailable(Execution exec) { if (exec.getAttribute(ATTR_UNAVAILABLE_GENED) == null && !exec.isAsyncUpdate(null)) { exec.setAttribute(ATTR_UNAVAILABLE_GENED, Boolean.TRUE); final Device device = exec.getDesktop().getDevice(); String s = device.getUnavailableMessage(); return s != null ? "<noscript>\n" + s + "\n</noscript>" : ""; } return ""; //nothing to generate }
/** Returns the doc type, or null if not available. * It is null or <!DOCTYPE ...>. */ public static final String outDocType(Execution exec, Page page) { if (exec.getAttribute(DOCTYPE_GENED) == null && !exec.isAsyncUpdate(null)) { exec.setAttribute(DOCTYPE_GENED, Boolean.TRUE); final String docType = ((PageCtrl) page).getDocType(); return trimAndLF(docType != null ? docType : page.getDesktop().getDevice().getDocType()); } return ""; }
public void redraw(java.io.Writer out) throws java.io.IOException { if (_tagnm == null) throw new UiException("The tag name is not initialized yet"); final Execution exec = Executions.getCurrent(); if (exec == null || exec.isAsyncUpdate(null) || !HtmlPageRenders.isDirectContent(exec)) { super.redraw(out); // generate JavaScript return; } TagRenderContext rc = PageRenderer.getTagRenderContext(exec); final boolean rcRequired = rc == null; Object ret = null; if (rcRequired) { ret = PageRenderer.beforeRenderTag(exec); rc = PageRenderer.getTagRenderContext(exec); } out.write(getPrologHalf(false)); rc.renderBegin(this, getClientEvents(), getSpecialRendererOutput(this), false); redrawChildrenDirectly(rc, exec, out); out.write(getEpilogHalf()); rc.renderEnd(this); if (rcRequired) { out.write(rc.complete()); PageRenderer.afterRenderTag(exec, ret); } }
public void onPiggyback() { //Note: we don't post ON_PIGGYBACK twice in an execution //(performance concern and back-compatibility). if (_piggybackListened && Executions.getCurrent().getAttribute(ATTR_PIGGYBACK_POSTED) == null) { for (Page page : _pages) { if (Executions.getCurrent().isAsyncUpdate(page)) { //ignore new created pages for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) { if (Events.isListened(root, Events.ON_PIGGYBACK, false)) { //asap+deferrable Events.postEvent(new Event(Events.ON_PIGGYBACK, root)); Executions.getCurrent().setAttribute(ATTR_PIGGYBACK_POSTED, Boolean.TRUE); } } } } } if (!_schedInfos.isEmpty()) Events.postEvent(ON_SCHEDULE, _dummyTarget, null); //we could not process them here (otherwise, event handling, thread //might not work) //Thus, we post an event and handle it in _dummyTarget if (_spush != null) _spush.onPiggyback(); }