List<String> links = new ArrayList<String>(); ListView listView = new ListView("linksId", links") { void populateItem( .... ) { IModel<String> model = getModel(); (or whatever its called) Link link = new Link("linkId", model ); item.add(link); } }
Markup will be something like: <ol> <li wicket:id="linksId"> <a wicket:id="linkId"></a> </li> </ol> Nick On Sat, Mar 2, 2013 at 5:26 PM, Stephen Walsh <step...@connectwithawalsh.com > wrote: > I think that's what I'm having trouble with. I have created the list view > like this: > > // define menu items > final List<Link> sidebarMenu = new ArrayList<Link>(); > sidebarMenu.add(new Link("new") { > public void onClick() { > setResponsePage(new EditBlogEntry(new Blog())); > } > }); > > // put them into a model > IModel sidebarLDM = new LoadableDetachableModel() { > @Override > protected Object load() { > return sidebarMenu; > } > }; > > // pass the model to the panel constructor > add(new SidebarPanel("sidebar", sidebarLDM)); > > public SidebarPanel(String id, IModel sidebarMenu) { > super(id, sidebarMenu); > > add(new ListView("sidebarMenuItems", sidebarMenu) { > @Override > protected void populateItem(ListItem item) { > item.add((Link)item.getModelObject()); > } > }); > } > > I'm not sure what the markup needs to look like for the html > > For my base page I have this to include the panel with the repeater: > <div wicket:id="sidebar"> > > </div> > > But I'm not sure what to put in the html for the actual panel with the list > view > > <wicket:panel> > <div wicket:id="sidebarMenuItems"> > </div> > </wicket:panel> > > This is what I started with and it's not working currently. > > Thanks for the help. > > > > _______________________________________ > Stephen Walsh | http://connectwithawalsh.com > > > On Sat, Mar 2, 2013 at 3:45 PM, Nick Pratt <nbpr...@gmail.com> wrote: > > > You can use a ListView or any of the other repeaters to achieve this. > > > > Your repeated markup will be an anchor. > > > > N > > On Mar 2, 2013 3:35 PM, "Stephen Walsh" <step...@connectwithawalsh.com> > > wrote: > > > > > I want to create a sidebar panel that is dynamic based on the links > > attach > > > to it. So far I have created a LDM that gets the list view of links > > that I > > > create. I pass the LDM the sidebar panel constructor and Wicket is > > > complaining about not having the markup for the link that is passed. > > > Obviously this makes sense, but I'm not quite sure how to markup the > > html > > > when I don't know what it's going to look like necessarily? > > > > > > I've been looking at containers and enclosures but I'm not quite > getting > > > it. > > > > > > Any thoughts on this? I search all over google and couldn't find > exactly > > > what I was looking for. > > > > > > Thanks! > > > _______________________________________ > > > Stephen Walsh | http://connectwithawalsh.com > > > > > >