Hi, On Tue, Oct 23, 2012 at 10:49 AM, Decebal Suiu <decebal.s...@asf.ro> wrote: > public class DesignModeListener implements IComponentInstantiationListener { > > private boolean designMode = true; > > @Override > public void onInstantiation(Component component) { > if (component instanceof WebMarkupContainer) { > Class<?> klass = component.getClass(); > while (klass.isAnonymousClass()) { > klass = klass.getSuperclass(); > } > > if (klass.getName().startsWith("com.acme")) { > component.add(new DesignModeBehavior()); > } > } > } > > private class DesignModeBehavior extends Behavior { > > private static final long serialVersionUID = 1L; > > @Override > public void beforeRender(Component component) { > super.beforeRender(component); > > if (designMode) { > // TODO > Class<?> klass = component.getClass(); > while (klass.isAnonymousClass()) { > klass = klass.getSuperclass(); > } > > Response response = component.getResponse(); > response.write("\n"); > } > } > > @Override > public void afterRender(Component component) { > super.afterRender(component); > > if (designMode) { > // TODO > Class<?> klass = component.getClass(); > while (klass.isAnonymousClass()) { > klass = klass.getSuperclass(); > } > > Response response = component.getResponse(); > response.write("\n"); > } > } > > } > > } > > In WicketApplication.init(): getComponentInstantiationListeners().add(new > DesignModeListener()); > > In WebPage.java: add(new HeaderPanel("header")); > > In WebPage.html: <div wicket:id="header" id="header"></div> > > My problem is that DesignModeBehavior decorates HeaderPanel with two > comments (before and after component tag) but the behavior what I want to > achieve is the same with setOutputMarkupContainerClassName on DebugSettings > (see MarkupContainer.renderAssociatedMarkup) - the comments are placed > before and after component tag body. > > Is it more clear now?
Yes, it is more clear. There was a similar question few days ago by Jesse Long in users@ - subject "Behavior modifying component body". Currently Behavior.java doesn't provide methods to write in the component tag body. You can use AbstractTransformBehavior as a workaround. > > Best regards, > Decebal > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/something-similar-with-setOutputMarkupContainerClassName-tp4653202p4653243.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org