List of usage examples for org.apache.wicket.markup MarkupStream throwMarkupException
public void throwMarkupException(final String message)
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 www . j a v a2 s .com*/ 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. * /* w w w . j a v a2 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:org.efaps.ui.wicket.components.LabelComponent.java
License:Apache License
/** * Method is overwritten to prevent the annoing warnings from Component to come up. * The warning come up due to the reason that this component moves the tags from parent * element to its child./*from w ww . j a v a 2 s . com*/ */ @Override protected void onRender() { final IMarkupFragment markup = getMarkup(); if (markup == null) { throw new MarkupException("Markup not found. Component: " + toString()); } final MarkupStream markupStream = new MarkupStream(markup); // Get mutable copy of next tag final ComponentTag openTag = markupStream.getTag(); final ComponentTag tag = openTag.mutable(); // Call any tag handler onComponentTag(tag); // If we're an openclose tag if (!tag.isOpenClose() && !tag.isOpen()) { // We were something other than <tag> or <tag/> markupStream.throwMarkupException("Method renderComponent called on bad markup element: " + tag); } if (tag.isOpenClose() && openTag.isOpen()) { markupStream.throwMarkupException("You can not modify a open tag to open-close: " + tag); } markupStream.next(); getMarkupSourcingStrategy().onComponentTagBody(this, markupStream, tag); }