List of usage examples for org.apache.wicket.markup MarkupStream atCloseTag
public boolean atCloseTag()
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. * /* w w w .j a va 2s. co 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: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;//from w w w . jav 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; } } } } }