You should do this:
WMC wmc = new WMC("childContainer") {
@override boolean isTransparentResolver() { return true; }
};
This is not a bug. If you do add() in the subclass's constructor, you
add to the page itself. Which is how the hierarchy is constructed. By
telling the WMC that it is a transparent resolver, you tell it to look
for children without attached markup in its siblings.
Martijn
On 4/5/08, Oliver Sawade <[EMAIL PROTECTED]> wrote:
> Hi everyone,
> my first mail to the list, i hope this wasn`t answered million times
> before, but the wicket users faq is empty so i couldn`t find it there ;)
>
> I'm using wicket1.3 to create a generic panel with the option to hide
> everything inside when clicking an ajax-button. While the actual
> hiding&showing works fine I'm having trouble with inheritance.
> This example should show what I mean:
>
> This is my generic super panel (no ajax stuff in it here to show the
> essential problem). The idea is, that the childContainer is set to
> Visible:false when the button is clicked. All of this should happen in the
> super class, so i don't have to care about it in the child class:
>
> public class testSuperPanel extends Panel {
> public testSuperPanel(String id) {
> super(id);
> add(new WebMarkupContainer("childContainer"));
> }
> }
>
> The markup for testSuperPanel:
> <wicket:panel>
> <div wicket:id="childContainer">
> <wicket:child/>
> </div>
> </wicket:panel>
>
> This is a sample child panel:
>
> public class testChildPanel extends testSuperPanel {
> public testChildPanel(String id) {
> super(id);
> add(new Label("childLabel","Test!"));
> }
> }
>
> and the Markup:
> <wicket:extend>
> <span wicket:id="childLabel"></span>
> </wicket:extend>
>
> As you see, it should simply display "Test" inside a MarkupContainer (which
> could be hidden from the superClass). When i try to display this Panel
> however I get an Exception stating that no code is added for the Label
> "childLabel"!
> This can be solved by adding the childLabel to the container in the
> superClass, but thats obviously not the way it is meant to be:
>
> public class testSuperPanel extends Panel {
> public testSuperPanel(String id) {
> super(id);
> WebMarkupContainer wmc = new
> WebMarkupContainer("childContainer");
> wmc.add(new Label("childLabel","Test!"));
> add(wmc);
> }
> }
>
> So, is this a wicket bug with inheritance inside containers or am I just
> doing things the wrong way?
>
> Thanks for your help!
> best regards, Oli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.2 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.2
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]