use of org.apache.wicket.markup.MarkupStream in project wicket by apache.
the class BorderBehavior method afterRender.
@Override
public void afterRender(final Component component) {
final MarkupStream stream = getMarkupStream(component);
final Response response = component.getResponse();
while (stream.isCurrentIndexInsideTheStream()) {
MarkupElement elem = stream.get();
stream.next();
if (elem instanceof WicketTag) {
WicketTag wTag = (WicketTag) elem;
if (wTag.isBorderTag() && wTag.isClose()) {
break;
} else {
throw new WicketRuntimeException("Unexpected tag encountered in markup of component border " + getClass().getName() + ". Tag: " + wTag.toString() + ", expected tag: </wicket:border>");
}
}
response.write(elem.toCharSequence());
}
}
use of org.apache.wicket.markup.MarkupStream in project wicket by apache.
the class HtmlHeaderSectionHandler method handleHeadTag.
/**
* Handle tag <head>
* @param tag
*/
private void handleHeadTag(ComponentTag tag) {
// we found <head>
if (tag.isOpen()) {
if (foundHead) {
throw new MarkupException(new MarkupStream(markup), "Tag <head> is not allowed at this position (do you have multiple <head> tags in your markup?).");
}
foundHead = true;
if (tag.getId() == null) {
tag.setId(HEADER_ID);
tag.setAutoComponentTag(true);
tag.setModified(true);
tag.setAutoComponentFactory(HTML_HEADER_FACTORY);
}
} else if (tag.isClose()) {
if (foundHeaderItemsTag) {
// revert the settings from above
ComponentTag headOpenTag = tag.getOpenTag();
// change the id because it is special. See HtmlHeaderResolver
headOpenTag.setId(HEADER_ID + "-Ignored");
headOpenTag.setAutoComponentTag(false);
headOpenTag.setModified(false);
headOpenTag.setFlag(ComponentTag.RENDER_RAW, true);
headOpenTag.setAutoComponentFactory(null);
}
foundClosingHead = true;
}
}
use of org.apache.wicket.markup.MarkupStream in project wicket by apache.
the class HtmlHeaderSectionHandler method handleHeaderItemsTag.
/**
* Handle tag <wicket:header-items>
*
* @param tag
*/
private void handleHeaderItemsTag(ComponentTag tag) {
if ((tag.isOpen() || tag.isOpenClose()) && foundHeaderItemsTag) {
throw new MarkupException(new MarkupStream(markup), "More than one <wicket:header-items/> detected in the <head> element. Only one is allowed.");
} else if (foundClosingHead) {
throw new MarkupException(new MarkupStream(markup), "Detected <wicket:header-items/> after the closing </head> element.");
}
foundHeaderItemsTag = true;
tag.setId(HEADER_ID);
tag.setAutoComponentTag(true);
tag.setModified(true);
tag.setAutoComponentFactory(HTML_HEADER_ITEMS_FACTORY);
}
use of org.apache.wicket.markup.MarkupStream in project wicket by apache.
the class FragmentMarkupSourcingStrategy method onComponentTagBody.
/**
* Skip the body markup associated with the 'component'. The body markup is expected to be raw
* markup only, not containing an wicket component. The body markup may serve documentary
* purposes for the developer / designer.
* <p>
* Than search for the markup of the fragment, effectively replacing the original markup.
*/
@Override
public void onComponentTagBody(final Component component, final MarkupStream markupStream, final ComponentTag openTag) {
// Skip the body markup making sure it contains only raw markup
super.onComponentTagBody(component, markupStream, openTag);
// Get the fragments open tag
MarkupStream stream = new MarkupStream(getMarkup((MarkupContainer) component, null));
ComponentTag fragmentOpenTag = stream.getTag();
// if it is an open close tag, skip this fragment.
if (!fragmentOpenTag.isOpenClose()) {
// We'll completely ignore the fragments open tag. It'll not be rendered
stream.next();
// Render the body of the fragment
component.onComponentTagBody(stream, fragmentOpenTag);
}
}
use of org.apache.wicket.markup.MarkupStream in project wicket by apache.
the class HeaderSectionMyLabel method newMarkupSourcingStrategy.
@Override
protected IMarkupSourcingStrategy newMarkupSourcingStrategy() {
return new PanelMarkupSourcingStrategy(false) {
@Override
public IMarkupFragment getMarkup(final MarkupContainer parent, final Component child) {
MarkupStream markup = new MarkupStream(parent.getAssociatedMarkup());
markup.skipRawMarkup();
return markup.getMarkupFragment();
}
@Override
public void onComponentTagBody(Component component, MarkupStream markupStream, ComponentTag openTag) {
HeaderSectionMyLabel.this.onComponentTagBody(markupStream, openTag);
}
};
}
Aggregations