Sorry, this was wicket 1.6.16 and 1.6.17. Here is a quickstart, to reproduce both cases some comments have to be switched: https://github.com/tkruse/custommarkup
On Mon, Sep 15, 2014 at 7:50 PM, Sven Meier <s...@meiers.net> wrote: > Hi, > > which Wicket version? > > The first approach leads to a MarkupException here with Wicket 1.6.x. > > Regards > Sven > > > On 09/15/2014 07:37 PM, Thibault Kruse wrote: >> >> Hi, >> >> I am trying to create a wicket panel that renders markup from some >> remote source, but if fetching fails, renders some fallback markup. I >> want to achieve this with minimal code. >> >> I tried two approaches one based on overriding getMarkup(), one based >> on http://wicket.apache.org/guide/guide/advanced.html#advanced_5, both >> fail: >> >> /** >> * attempts to use custom markup by overriding getMarkup()... but html is >> used >> */ >> public class CustomMarkupFallback1Panel extends GenericPanel<String> { >> @Override >> public IMarkupFragment getMarkup() { >> return Markup.of("it works"); >> } >> } >> >> CustomMarkupFallback1Panel.html: >> <wicket:panel> >> Fail! >> </wicket:panel> >> >> >> This first one overrides getMarkup() as suggested in the javadoc of >> IMarkupResourceStreamProvider, but what gets rendered is instead the >> static html (even though the debugger walks through getMarkup(). >> >> >> The second approach fails using IMarkupResourceStreamProvider works >> for the intended markup, but not for the fallback markup >> public class CustomMarkupFallback2Panel extends GenericPanel<String> >> IMarkupResourceStreamProvider { >> >> @Override >> public IResourceStream getMarkupResourceStream(MarkupContainer >> container, Class<?> containerClass) { >> if (getModelObject() == null) { >> // thows Exception, see below. html file exists >> return getMarkup().getMarkupResourceStream(); >> } else { >> // works >> return new StringResourceStream(getModelObject()); >> } >> } >> } >> >> >> At least the first failure seems like a bug to me, not sure whether >> the second approach is supposed to work, or how else to load markup >> the wicket way. >> >> Is there maybe a completely different approach to achieve what I try to >> do? >> >> cheers, >> Thibault >> >> >> >> java.io.IOException: Stream closed >> at >> java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162) >> at java.io.BufferedInputStream.read(BufferedInputStream.java:325) >> at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) >> at java.io.BufferedInputStream.read(BufferedInputStream.java:254) >> at >> org.apache.wicket.util.io.BOMInputStream.getBOM(BOMInputStream.java:217) >> at >> org.apache.wicket.util.io.BOMInputStream.readFirstBytes(BOMInputStream.java:261) >> at >> org.apache.wicket.util.io.BOMInputStream.read(BOMInputStream.java:312) >> at >> org.apache.wicket.util.io.XmlReader.getXmlDeclaration(XmlReader.java:183) >> at org.apache.wicket.util.io.XmlReader.init(XmlReader.java:106) >> at org.apache.wicket.util.io.XmlReader.<init>(XmlReader.java:81) >> at >> org.apache.wicket.markup.parser.XmlPullParser.parse(XmlPullParser.java:605) >> at >> org.apache.wicket.markup.AbstractMarkupParser.parse(AbstractMarkupParser.java:178) >> at >> org.apache.wicket.markup.loader.SimpleMarkupLoader.loadMarkup(SimpleMarkupLoader.java:51) >> at >> org.apache.wicket.markup.loader.InheritedMarkupMarkupLoader.loadMarkup(InheritedMarkupMarkupLoader.java:57) >> at >> org.apache.wicket.markup.loader.DefaultMarkupLoader.loadMarkup(DefaultMarkupLoader.java:52) >> at >> org.apache.wicket.markup.MarkupFactory.loadMarkup(MarkupFactory.java:412) >> at >> org.apache.wicket.markup.MarkupCache.loadMarkup(MarkupCache.java:448) >> at >> org.apache.wicket.markup.MarkupCache.loadMarkupAndWatchForChanges(MarkupCache.java:544) >> at >> org.apache.wicket.markup.MarkupCache.getMarkup(MarkupCache.java:305) >> at >> org.apache.wicket.markup.MarkupFactory.getMarkup(MarkupFactory.java:236) >> at >> org.apache.wicket.markup.MarkupFactory.getMarkup(MarkupFactory.java:194) >> at >> org.apache.wicket.MarkupContainer.getAssociatedMarkup(MarkupContainer.java:405) >> at >> org.apache.wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.java:372) >> at >> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderHeadFromAssociatedMarkupFile(AssociatedMarkupSourcingStrategy.java:244) >> at >> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderHead(AssociatedMarkupSourcingStrategy.java:220) >> at org.apache.wicket.Component.renderHead(Component.java:2652) >> at >> org.apache.wicket.markup.renderStrategy.ChildFirstHeaderRenderStrategy$1.component(ChildFirstHeaderRenderStrategy.java:85) >> at >> org.apache.wicket.markup.renderStrategy.DeepChildFirstVisitor.visit(DeepChildFirstVisitor.java:96) >> at >> org.apache.wicket.markup.renderStrategy.DeepChildFirstVisitor.visit(DeepChildFirstVisitor.java:87) >> at >> org.apache.wicket.markup.renderStrategy.DeepChildFirstVisitor.visit(DeepChildFirstVisitor.java:51) >> at >> org.apache.wicket.markup.renderStrategy.ChildFirstHeaderRenderStrategy.renderChildHeaders(ChildFirstHeaderRenderStrategy.java:78) >> at >> org.apache.wicket.markup.renderStrategy.ChildFirstHeaderRenderStrategy.renderHeader(ChildFirstHeaderRenderStrategy.java:57) >> at >> org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:170) >> at >> org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:71) >> at >> org.apache.wicket.Component.internalRenderComponent(Component.java:2514) >> at >> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1496) >> at org.apache.wicket.Component.internalRender(Component.java:2344) >> at org.apache.wicket.Component.render(Component.java:2272) >> at >> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1392) >> at >> org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1557) >> at org.apache.wicket.Page.onRender(Page.java:887) >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org