Hi,

Thanks for your reply. I'm pretty much doing what you suggested but have a
concrete Tab class as it is reused on another page:

public class AlbumTab extends AbstractTab {

        private static final long serialVersionUID = 1L;
        private IModel<Album> model;

        public AlbumTab(IModel<Album> model) {
                super(new PropertyModel<String>(model, "name"));
                this.model = model;
        }

        @Override
        public Panel getPanel(String id) {
                return new TabPanel(id, model);
        }
}

The Page has a hibernate backed LoadableDetachableModel - AlbumGroup.
AlbumGroup has a list of Albums. I iterate through the list and create a tab
for each Album and create a tabbed panel:

//create a tab for each album
List<ITab> tabs = new ArrayList<ITab>();
for (Album album: model.getObject().getAlbums()) {
        ITab tab = new AlbumTab(new Model<Album>(album));
        tabs.add(tab);
}
add(new TabbedPanel("content-tabs", tabs));

My confusion was/is on who calls detach() on the LDM. Each tab will have a
reference to the LDM.

I am now setting the LDM as the default model for the page (even though the
page does not use it). My reasoning is that once the page is Serialised, it
will call detach() on the LDM.


Any thoughts on my approach?
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Dynamic-tab-question-now-to-pass-a-model-to-the-panel-tp3250387p3252157.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to