In Wicket 1.4, I am trying to allow child pages to change the CSS class on a tag on the parent page, which I do all the time. What is strange in this case is that the tag I want to target is wrapping the layout of the child page . Here was a simplified snapshot of what I tried:
ParentPage.html
<div id="main" wicket:id="main"> <wicket:child /> </div>
ParentPage.java
public abstract class ParentPage { private WebMarkupContainer main; protected ParentPage() { main = new WebMarkupContainer("main"); add(main); } public void setClassAttr(String cssClass){ main.add(SimpleAttributeModifier("class", cssClass); } }
ChildPage.html
<wicket:extend> ... </wicket:extend>
ChildPage.java
public class ChildPage extends Page { ... public ChildPage() { super(); ... setClassAttr("specific-class-for-this-page"); } }
... Which explodes because it displays HTML from child downloads, but not java. (If I remove the gate: id and java code on div#main , everything will be fine.)
Note that the parent tag I want to manipulate with the child actually wraps the wicket:child tag. In other cases, I did something similar, tags that I want monkeys, which are usually siblings or otherwise removed from the wicket:child tag.
All I really want to do is let the child change the class attribute for the parent - is there any other way to do this? Why can't a child page be inserted into another component of a Wicket page?
source share