On Fri, Nov 25, 2011 at 1:26 PM, Fabiosakiyam <fabiosakiy...@gmail.com>wrote:
> Hi Bertrand, > > I have almost the same problem you do (i think, im still a newbie). > I'm trying to create a component that creates one specific container, > depending on it's type. So i'd like to add only this container. I'm having > problem at the .html, since i don't know if i should declare all > wicket:id="idContainer" or just the chosen one, since each container have > it's own .html, how to 'link' the component html to the container .html. > > I want to know what you did on your .html, 'cause since your adding only > the > chosen panel to add, how you declared all possible panels on the .html? i > wonder if you declared all panels on the .html or only the chosen one... I think I just responded to you in your own thread - where I didn't know what you were trying to do. I still don't claim to fully understand, but I think I better understand your question here. If you mean that you have one panel that *may possibly contain any one of X panels*, then here's one solution: ContainingPanel.html: <wicket:panel> Some markup here Blah, blah, blah... <div wicket:id="childPanel"></div> More surrounding markup... </wicket:panel> ContainingPanel.java: class ContainingPanel extends Panel { public void onBeforeRender() { if(getModelObject() is of some type) { addOrReplace(new SomePanel("childPanel")); } else if(getModelObject() is of some other type) { addOrReplace(new SomeOtherPanel("childPanel")); } } } You only need one wicket:id in your containing panel. You just swap at runtime which component actually shows up in that spot. -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org*