/** * Resets markup stream to the original position */ public void rewind() { markupStream.setCurrentIndex(originalIndex); }
/** * Resets markup stream to the original position */ public void rewind() { markupStream.setCurrentIndex(originalIndex); }
public void visitItem(TreeItem item) { // rewind markup stream markupStream.setCurrentIndex(markupStart); // render component item.render(markupStream); rendered.rendered = true; } };
/** * Construct. * * @param markup * @param message * @param cause */ public MarkupException(final Markup markup, final String message, final Throwable cause) { this(new MarkupStream(markup).setCurrentIndex(markup.size() - 1), message, cause); }
/** * Construct. * * @param markup * @param message * @param cause */ public MarkupException(final Markup markup, final String message, final Throwable cause) { this(new MarkupStream(markup).setCurrentIndex(markup.size() - 1), message, cause); }
/** * Renders all child items in no specified order * * @param markupStream * The markup stream */ @Override protected final void onRender(final MarkupStream markupStream) { final int markupStart = markupStream.getCurrentIndex(); Iterator<? extends Component> it = renderIterator(); if (it.hasNext()) { do { Component child = it.next(); if (child == null) { throw new IllegalStateException("the render iterator returned null for a child"); } markupStream.setCurrentIndex(markupStart); renderChild(child); } while (it.hasNext()); } else { markupStream.skipComponent(); } }
/** * Renders all child items in no specified order * * @param markupStream * The markup stream */ protected final void onRender(final MarkupStream markupStream) { final int markupStart = markupStream.getCurrentIndex(); Iterator it = renderIterator(); if (it.hasNext()) { do { Component child = (Component)it.next(); if (child == null) { throw new IllegalStateException("the render iterator returned null for a child"); } markupStream.setCurrentIndex(markupStart); renderChild(child); } while (it.hasNext()); } else { markupStream.skipComponent(); } }
public void visitItem(TreeItem item) { // rewind markupStream markupStream.setCurrentIndex(index); // render child item.onRender(markupStream); // go through the behaviors and invoke IBehavior.afterRender List<IBehavior> behaviors = item.getBehaviors(); for (IBehavior behavior : behaviors) { behavior.afterRender(item); } } });
/** * @see org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket.markup.MarkupStream, * org.apache.wicket.markup.ComponentTag) */ protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { if (wasOpenCloseTag == false) { // It is open-preview-close. Only RawMarkup is allowed within // the preview region, which gets stripped from output markupStream.skipRawMarkup(); } // this check always results in false for normal requests. // in case of ajax requests, the markupstream is not reset after the first render, thus // the current index of the markup stream points to the element after the body. // as a result, no elements are detected and always omitted. if (beginOfBodyIndex != originalMarkupStream.getCurrentIndex()) { originalMarkupStream.setCurrentIndex(beginOfBodyIndex); } super.onComponentTagBody(originalMarkupStream, Border.this.openTag); }
/** * @see org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket.markup.MarkupStream, * org.apache.wicket.markup.ComponentTag) */ @Override protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { if (wasOpenCloseTag == false) { // It is open-preview-close. Only RawMarkup is allowed within // the preview region, which gets stripped from output markupStream.skipRawMarkup(); } // this check always results in false for normal requests. // in case of ajax requests, the markupstream is not reset after the first render, thus // the current index of the markup stream points to the element after the body. // as a result, no elements are detected and always omitted. if (beginOfBodyIndex != originalMarkupStream.getCurrentIndex()) { originalMarkupStream.setCurrentIndex(beginOfBodyIndex); } super.onComponentTagBody(originalMarkupStream, Border.this.openTag); }
/** * Position the markup stream at the child component relative to the <b>provider</b> markup * * @param path * @return The markup stream for the given component. */ public MarkupStream findComponentIndex(final String path) { MarkupStream markupStream = getAssociatedMarkupStream(true); int index = markupStream.findComponentIndex(markupId, path); if (index == -1) { throw new MarkupException("Markup of component class `" + markupStream.getContainerClass().getName() + "` does not contain a fragment with wicket:id `" + markupId + "`. Context: " + toString()); } markupStream.setCurrentIndex(index); return markupStream; }
@Override protected void executeInsideBufferedZone() { final int ind = markupStream.findComponentIndex(tag.getPath(), tag.getId()); markupStream.setCurrentIndex(ind); ComponentResolvers.resolve(getApplication(), container, markupStream, tag); } }.execute();
/** * Position the markup stream at the child component relative to the <b>provider</b> markup * * @param path * @return The markup stream for the given component. */ public MarkupStream findComponentIndex(final String path) { MarkupStream markupStream = getAssociatedMarkupStream(true); int index = markupStream.findComponentIndex(associatedMarkupId, path); if (index == -1) { throw new MarkupException("Markup of component class `" + markupStream.getContainerClass().getName() + "` does not contain a fragment with wicket:id `" + associatedMarkupId + "`. Context: " + toString()); } markupStream.setCurrentIndex(index); return markupStream; }
@Override protected void executeInsideBufferedZone() { final int ind = markupStream.findComponentIndex(tag.getPath(), tag.getId()); markupStream.setCurrentIndex(ind); ComponentResolvers.resolve(getApplication(), container, markupStream, tag); } }.execute();
@Override public void onComponentTagBody(MarkupStream markupStream, final ComponentTag openTag) { int beginOfBodyIndex = markupStream.getCurrentIndex(); Response response = new StringResponse(); RequestCycle requestCycle = getRequestCycle(); Response webResponse = requestCycle.setResponse(response); try { super.onComponentTagBody(markupStream, openTag); webResponse.write(response.toString()); } catch (WicketRuntimeException ex) { log.error("runtime plugin failure", ex); // this is a plugin, don't let the entire UI fail because of it failing markupStream.setCurrentIndex(beginOfBodyIndex); markupStream.skipToMatchingCloseTag(openTag); } finally { requestCycle.setResponse(webResponse); } }
@Override protected void onComponentTagBody(MarkupStream markupStream, final ComponentTag openTag) { MarkupStream originalMarkupStream = getMarkupStream(); int beginOfBodyIndex = originalMarkupStream.getCurrentIndex(); Response response = new StringResponse(); RequestCycle requestCycle = getRequestCycle(); Response webResponse = requestCycle.setResponse(response); try { super.onComponentTagBody(markupStream, openTag); webResponse.write(response.toString()); } catch (WicketRuntimeException ex) { log.error("runtime plugin failure", ex); // this is a plugin, don't let the entire UI fail because of it failing markupStream.setCurrentIndex(beginOfBodyIndex); markupStream.skipToMatchingCloseTag(openTag); } finally { requestCycle.setResponse(webResponse); } }
protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { final String key = getModelObjectAsString(); final String value = getLocalizer().getString(key, getParent(), DEFAULT_VALUE); if (value != null && !DEFAULT_VALUE.equals(value)) { replaceComponentTagBody(markupStream, openTag, value.trim()); } else { log.debug("No value found for wicket:message tag with key: {}", key); // get original tag from markup because we modified this one to always be open markupStream.setCurrentIndex(markupStream.getCurrentIndex() - 1); ComponentTag tag = markupStream.getTag(); markupStream.next(); // if the tag is of form <wicket:message>{foo}</wicket:message> use {foo} as // default value for the message, otherwise do nothing if (!tag.isOpenClose()) { MarkupElement body = markupStream.get(); if (body instanceof RawMarkup) { replaceComponentTagBody(markupStream, openTag, body.toCharSequence()); } } } }
public CharSequence execute() { final int originalStreamPos = stream.getCurrentIndex(); final Response original = cycle.getResponse(); final StringResponse buffer = new StringResponse(); cycle.setResponse(buffer); try { executeInsideBufferedZone(); return buffer.getBuffer(); } finally { cycle.setResponse(original); stream.setCurrentIndex(originalStreamPos); } }
public CharSequence execute() { final int originalStreamPos = stream.getCurrentIndex(); final Response original = cycle.getResponse(); final StringResponse buffer = new StringResponse(); cycle.setResponse(buffer); try { executeInsideBufferedZone(); return buffer.getBuffer(); } finally { cycle.setResponse(original); stream.setCurrentIndex(originalStreamPos); } }
public CharSequence execute() { final int originalStreamPos = stream.getCurrentIndex(); final Response original = cycle.getResponse(); final StringResponse buffer = new StringResponse(); cycle.setResponse(buffer); try { executeInsideBufferedZone(); return buffer.getBuffer(); } finally { cycle.setResponse(original); stream.setCurrentIndex(originalStreamPos); } }