I accidently sent it incomplete ... here is full code RepeatingView rp = new RepeatingView(); for(int i =0; i< n; i++){ WebMarkupContainer parent = new WebMarkupContainer(rp.newChildID()); rp.add(parent);
MyPanelData data =new MyPanelData(); this.getModelObject.getList().add(data); MyPanel panel = new MyPanel("panel", new CompoundPropertyModel(data)); parent.add(panel); } Jan Ferko 2010/10/24 Jan Ferko <julyl...@gmail.com> > Thanks a lot, it worked great. > > I have one more question. I have to create same panel multiple times , > based on user output into the form and i have list of panel data model > object inside my form data object. Is it better to generate panels in page > class and then passed list of panels into form constructor and use ListView > or generate it inside form with RepeatingView and create new instance of > PanelData in Cycle and setting it on Panel and saving it to list like > this... > > RepeatingView rp = new RepeatingView(); > for(int i =0; i< n; i++){ > WebMarkupContainer parent = new WebMarkupContainer(rp.newChildID()); > > } > > 2010/10/22 Jeremy Thomerson <jer...@wickettraining.com> > > On Fri, Oct 22, 2010 at 11:38 AM, Sven Meier <s...@meiers.net> wrote: >> >> > Hi Jan, >> > >> > when are data2 and data3 initialized? They seems to be null when you put >> up >> > your models. >> > >> > Most of the time it's a bad idea to pull something out of a model and >> put >> > it back into another model. >> > Do this instead: >> > >> > this.add(new MyPanel(id2, new PropertyModel(model, "data2"))); >> > >> > Then in MyPanel: >> > >> > public MyPanel(id, model){ >> > super(id, new CompoundPropertyModel(model)); >> > >> > This has the following advantages: >> > - MyPanel's model is always in sync with the model of MyForm. >> > - MyPanel's usage of CompoundPropertyModel is hidden from the outside. >> If >> > MyPanel want's to utilize a CompoundPropertyModel (because it doesn't >> set >> > the model on its contained components), it should set it up by itself. >> > >> > HTH >> > >> > Sven >> >> >> Sven is spot-on, and this method he showed you above will absolutely save >> you some bugs down the road! >> >> Thanks Sven!! >> >> -- >> Jeremy Thomerson >> http://wickettraining.com >> *Need a CMS for Wicket? Use Brix! http://brixcms.org* >> > > > > -- > Jan Ferko, > julyl...@gmail.com > -- Jan Ferko, julyl...@gmail.com