use of org.apache.wicket.markup.head.HeaderItem in project wicket by apache.
the class DecoratingHeaderResponseTest method decoratedStringPrepend.
/**
* Basic IHeaderResponseDecorator, just prepending the DECORATED string to resource name.
*
* @throws IOException
* @throws ResourceStreamNotFoundException
* @throws ParseException
*/
@Test
public void decoratedStringPrepend() throws IOException, ResourceStreamNotFoundException, ParseException {
tester.getApplication().setHeaderResponseDecorator(new IHeaderResponseDecorator() {
@Override
public IHeaderResponse decorate(IHeaderResponse response) {
return new ResourceAggregator(new DecoratingHeaderResponse(response) {
@Override
public void render(HeaderItem item) {
if (item instanceof JavaScriptReferenceHeaderItem) {
JavaScriptReferenceHeaderItem original = (JavaScriptReferenceHeaderItem) item;
item = JavaScriptHeaderItem.forReference(new PackageResourceReference("DECORATED-" + original.getReference().getName()), original.getId());
}
super.render(item);
}
});
}
});
tester.startPage(TestPage.class);
XmlPullParser parser = new XmlPullParser();
parser.parse(tester.getLastResponseAsString());
XmlTag tag = parser.nextTag();
boolean isDecorated = false;
do {
if (tag.isOpen() && "script".equals(tag.getName())) {
isDecorated = tag.getAttribute("src").toString().contains("DECORATED");
if (!isDecorated) {
fail();
}
break;
}
} while ((tag = parser.nextTag()) != null);
assertTrue(isDecorated);
}
use of org.apache.wicket.markup.head.HeaderItem in project wicket by apache.
the class WicketWebSocketJQueryResourceReference method getDependencies.
@Override
public List<HeaderItem> getDependencies() {
final ResourceReference wicketAjaxReference;
if (Application.exists()) {
wicketAjaxReference = Application.get().getJavaScriptLibrarySettings().getWicketAjaxReference();
} else {
wicketAjaxReference = WicketAjaxJQueryResourceReference.get();
}
List<HeaderItem> dependencies = super.getDependencies();
dependencies.add(JavaScriptHeaderItem.forReference(wicketAjaxReference));
return dependencies;
}
Aggregations