List of usage examples for org.apache.wicket.markup MarkupStream getCurrentIndex
public int getCurrentIndex()
From source file:com.servoy.j2db.server.headlessclient.dataui.SortableCellViewHeaders.java
License:Open Source License
private void renderSortableCellViewHeaderTagBody(final MarkupStream markupStream, final ComponentTag openTag) { renderColumnIdx = 0;/*from ww w . ja va2 s . co m*/ headerMarkupStartIdx = markupStream.getCurrentIndex(); orderedHeaders = view.getOrderedHeaders(); orderedHeaderIds = view.getOrderedHeaderIds(); if ((markupStream != null) && (markupStream.getCurrentIndex() > 0)) { // If the original tag has been changed from open-close to open-body-close, // than historically renderComponentTagBody gets called, but actually // it shouldn't do anything since there is no body for that tag. ComponentTag origOpenTag = (ComponentTag) markupStream.get(markupStream.getCurrentIndex() - 1); if (origOpenTag.isOpenClose()) { return; } } // If the open tag requires a close tag boolean render = openTag.requiresCloseTag(); if (render == false) { // Tags like <p> do not require a close tag, but they may have. render = !openTag.hasNoCloseTag(); } if (render == true) { // Loop through the markup in this container while (markupStream.hasMore() && !markupStream.get().closes(openTag)) { // Render markup element. Doing so must advance the markup // stream final int index = markupStream.getCurrentIndex(); _renderNext(markupStream); if (index == markupStream.getCurrentIndex()) { markupStream.throwMarkupException( "Markup element at index " + index + " failed to advance the markup stream"); //$NON-NLS-1$ //$NON-NLS-2$ } } } }
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. * /* ww w .j a v a 2s . c o m*/ * @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:jp.xet.uncommons.wicket.gp.BookmarkableForm.java
License:Apache License
private void renderComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { if ((markupStream != null) && (markupStream.getCurrentIndex() > 0)) { ComponentTag origOpenTag = (ComponentTag) markupStream.get(markupStream.getCurrentIndex() - 1); if (origOpenTag.isOpenClose()) { return; }/* w ww.j a v a 2 s .c o m*/ } boolean render = openTag.requiresCloseTag(); if (render == false) { render = !openTag.hasNoCloseTag(); } if (render == true) { renderAll(markupStream, openTag); } }
From source file:org.dcm4chee.dashboard.ui.messaging.SideColumnsView.java
License:Apache License
/** * Renders the columns.// w w w .jav a2 s .c om * * @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 w w w . j a v a 2 s.c om @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 {//from w w w.j av a 2s. c o m 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); } }