List of usage examples for org.apache.wicket.markup MarkupStream setCurrentIndex
public MarkupStream setCurrentIndex(final int currentIndex)
From source file:com.servoy.j2db.server.headlessclient.dataui.SortableCellViewHeaders.java
License:Open Source License
/** * Renders the next element of markup in the given markup stream. * //from www. j av a 2 s .c om * @param markupStream The markup stream */ private final void _renderNext(final MarkupStream markupStream) { // Get the current markup element final MarkupElement element = markupStream.get(); // If it a tag like <wicket..> or <span wicket:id="..." > if ((element instanceof ComponentTag) && !markupStream.atCloseTag()) { // Get element as tag final ComponentTag tag = (ComponentTag) element; // Get component id final String id = tag.getId(); // Get the component for the id from the given container final Component component = get(id); // Failed to find it? if (component != null && orderedHeaders.get(renderColumnIdx) != null) { if (component instanceof SortableCellViewHeader) { int currentIdx = markupStream.getCurrentIndex(); renderHeader(renderColumnIdx, markupStream); renderColumnIdx++; markupStream.setCurrentIndex(currentIdx); markupStream.skipComponent(); } } else { // 2rd try: Components like Border and Panel might implement // the ComponentResolver interface as well. MarkupContainer container = this; while (container != null) { if (container instanceof SortableCellViewHeaders) { // we should created the corect header, use the id from the orderedHeaders String headerId = orderedHeaderIds.get(renderColumnIdx); renderColumnIdx++; if (resolve(markupStream, tag, headerId)) { return; } } if (container instanceof IComponentResolver) { if (((IComponentResolver) container).resolve(this, markupStream, tag)) { return; } } container = container.findParent(MarkupContainer.class); } // 3rd try: Try application's component resolvers final List<IComponentResolver> componentResolvers = getApplication().getPageSettings() .getComponentResolvers(); final Iterator<IComponentResolver> iterator = componentResolvers.iterator(); while (iterator.hasNext()) { final IComponentResolver resolver = iterator.next(); if (resolver.resolve(this, markupStream, tag)) { return; } } if (tag instanceof WicketTag) { if (((WicketTag) tag).isChildTag()) { markupStream.throwMarkupException("Found " + tag.toString() + " but no <wicket:extend>"); //$NON-NLS-1$ //$NON-NLS-2$ } else { markupStream.throwMarkupException("Failed to handle: " + tag.toString()); //$NON-NLS-1$ } } // No one was able to handle the component id markupStream.throwMarkupException("Unable to find component with id '" + id + "' in " + this //$NON-NLS-1$//$NON-NLS-2$ + ". This means that you declared wicket:id=" + //$NON-NLS-1$ id + " in your markup, but that you either did not add the " //$NON-NLS-1$ + "component to your page at all, or that the hierarchy does not match."); //$NON-NLS-1$ } } else { getResponse().write(element.toCharSequence()); markupStream.next(); } }
From source file:com.servoy.j2db.server.headlessclient.dataui.SortableCellViewHeaders.java
License:Open Source License
private void renderHeader(int headerIdx, final MarkupStream markupStream) { Component header = orderedHeaders.get(headerIdx); markupStream.setCurrentIndex(headerMarkupStartIdx); boolean found = false; MarkupElement element;// w ww . j a v a 2 s . c o m while (!found) { element = markupStream.next(); if ((element instanceof ComponentTag) && !markupStream.atCloseTag()) { // Get element as tag final ComponentTag tag = (ComponentTag) element; // Get component id final String id = tag.getId(); // Get the component for the id from the given container final Component component = get(id); // Failed to find it? if (component != null) { if (component.equals(header)) { component.render(markupStream); found = true; } } } } }
From source file:org.dcm4chee.dashboard.ui.messaging.SideColumnsView.java
License:Apache License
/** * Renders the columns.//from www . j a va 2s .com * * @param markupStream * The markup stream of this component */ @Override protected void onRender(final MarkupStream markupStream) { final int markupStart = markupStream.getCurrentIndex(); Response response = RequestCycle.get().getResponse(); boolean firstLeft = true; // whether there was no left column rendered // yet boolean rendered = false; for (int i = 0; i < columns.size(); ++i) { IColumn column = columns.get(i); Component component = components.get(i); IRenderable renderable = renderables.get(i); // write wrapping markup response.write("<span class=\"b_\" style=\"" + renderColumnStyle(column) + "\">"); if (column.getLocation().getAlignment() == Alignment.LEFT && firstLeft == true) { // for the first left column we have different style class // (without the left border) response.write("<span class=\"d_\">"); firstLeft = false; } else { if (i == 3) { QueueModel queueModel = (QueueModel) ((DefaultMutableTreeNode) node).getUserObject(); response.write("<span class=\"c_\"" + (queueModel.getColor() == null ? "" : "style=\"background-color: " + queueModel.getColor() + ";\"") + ">"); } else response.write("<span class=\"c_\">"); } if (component != null) { markupStream.setCurrentIndex(markupStart); component.render(markupStream); rendered = true; } else if (renderable != null) { renderable.render(node, response); } else { throw new IllegalStateException( "Either renderable or cell component must be created for this node"); } response.write("</span></span>\n"); } // if no component was rendered just advance in the markup stream if (rendered == false) { markupStream.skipComponent(); } }
From source file:org.efaps.ui.wicket.components.AbstractParentMarkupContainer.java
License:Apache License
/** * @see org.apache.wicket.MarkupContainer#onRender(org.apache.wicket.markup.MarkupStream) *//*from ww w . j av a 2 s . c o m*/ @Override public void onRender() { final IMarkupFragment markup = getMarkup(); final MarkupStream markupStream = new MarkupStream(markup); final int markupStart = markupStream.getCurrentIndex(); // Get mutable copy of next tag final ComponentTag openTag = markupStream.getTag(); final ComponentTag tag = openTag.mutable(); // Call any tag handler onComponentTag(tag); // Render open tag if (!getRenderBodyOnly()) { renderComponentTag(tag); } markupStream.next(); // Render the body only if open-body-close. Do not render if // open-close. if (tag.isOpen()) { // Render the body onComponentTagBody(markupStream, tag); } markupStream.setCurrentIndex(markupStart); final Iterator<?> childs = this.iterator(); while (childs.hasNext()) { markupStream.setCurrentIndex(markupStart); final Component child = (Component) childs.next(); child.rendered(); } markupStream.setCurrentIndex(markupStart); markupStream.next(); // Render close tag if (tag.isOpen()) { if (openTag.isOpen()) { // Get the close tag from the stream ComponentTag closeTag = markupStream.getTag(); // If the open tag had its id changed if (tag.isAutoComponentTag()) { // change the id of the close tag closeTag = closeTag.mutable(); closeTag.setName(tag.getName()); } // Render the close tag renderComponentTag(closeTag); markupStream.next(); } } }
From source file:org.hippoecm.frontend.service.render.AbstractRenderService.java
License:Apache License
@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 {/* ww w .ja va 2s. c om*/ 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); } }