Hi,
I have an interesting problem. I am trying to get a subclass of a
component to add it's children to a container in the superclass. This is
the markup:
SuperComponent.html
<html>
<body>
blahblahblah
<div wicket:id="myContainer">
blahblah
<wicket:child/>
</div>
blahblahblah
</body>
</html>
SubComponent.html
<wicket:extend>
<span wicket:id="myLabel">my label</span>
</wicket:extend>
The problem is that when in SubComponent.java I say:
this.add(new Label("myLabel", "label text"));
the label is added to the SuperComponent instead of myContainer. This is
an error in the markup hierarchy.
The solution that first came to mind was to override add(Component) in
SuperComponent so that it would add the added component to myContainer
instead of 'this'. Unforunately, the add method is final (why!?), so
this can't be done.
The workaround is to provide a addToContainer(Component) method. I think
this is ugly because SubComponent has to have intricate knowledge of
SuperComponent and use addToContainer where it would normally use add.
SubComponent already has some knowledge of SuperComponent anyway because
it's a subclass, but still I think it's ugly.
Is there another solution to my problem? Maybe using enclosure or border
or somesuch? Any ideas?
BTW: I use wicket 1.3.0-beta2.
Regards,
Matthijs
--
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]