RE: How to build a dynamic navigation bar
I'd use a ListView :) Assuming this lil code add( new ListView(list, linkList ) { public void populateItem(ListItem item) { item.add( (Link)linkList ); } }); You'd have the html look something like this ul wicket:id=list lia href=# wicket:id=linkIdLink text here/a/li /ul Just remember to add whatever you want to the item, and not just use add(...). http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/markup/html/list/ListView.html Alex -Opprinnelig melding- Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 18:08 Til: users@wicket.apache.org Emne: How to build a dynamic navigation bar Hello, I want to be able to build a left-side dynamic navigation bar based on user permissions. For example, if the user does not have access to the Prices page, I do not want to show the Prices link on the navigation bar. Also, since the link will point to a Wicket page, it has to be a Wicket link. This is how I would like the NavBar to appear: div id=mainNav ul li Home /li li Prices /li li Contracts /li li Products /li li Transactions /li /ul /div I tried using ListView, but I could not get it to work, as it forces the wicket id of the line items to be all the same. Thanks in advance. -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18592899.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to build a dynamic navigation bar
Thanks for the quick reply. Wouldn't this force all links to have the same wicket ids (linkid)? I'd like to be able to have the line items look like this: ul wicket:id=list li # Link01 text here /li li # Link02 text here /li li # Link03 text here /li /ul Alexander Landsnes Keül wrote: I'd use a ListView :) Assuming this lil code add( new ListView(list, linkList ) { public void populateItem(ListItem item) { item.add( (Link)linkList ); } }); You'd have the html look something like this ul wicket:id=list li # Link text here /li /ul Just remember to add whatever you want to the item, and not just use add(...). http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/markup/html/list/ListView.html Alex -Opprinnelig melding- Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 18:08 Til: users@wicket.apache.org Emne: How to build a dynamic navigation bar Hello, I want to be able to build a left-side dynamic navigation bar based on user permissions. For example, if the user does not have access to the Prices page, I do not want to show the Prices link on the navigation bar. Also, since the link will point to a Wicket page, it has to be a Wicket link. This is how I would like the NavBar to appear: div id=mainNav ul li Home /li li Prices /li li Contracts /li li Products /li li Transactions /li /ul /div I tried using ListView, but I could not get it to work, as it forces the wicket id of the line items to be all the same. Thanks in advance. -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18592899.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18593941.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to build a dynamic navigation bar
They need the same wicket:id yes, but that doesn't mean that they need the same text or targets. Just create as many links as you want/need, with whatever behaviour they need. Just make sure they all have the same id :) Alex -Opprinnelig melding- Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 19:00 Til: users@wicket.apache.org Emne: RE: How to build a dynamic navigation bar Thanks for the quick reply. Wouldn't this force all links to have the same wicket ids (linkid)? I'd like to be able to have the line items look like this: ul wicket:id=list li # Link01 text here /li li # Link02 text here /li li # Link03 text here /li /ul Alexander Landsnes Keül wrote: I'd use a ListView :) Assuming this lil code add( new ListView(list, linkList ) { public void populateItem(ListItem item) { item.add( (Link)linkList ); } }); You'd have the html look something like this ul wicket:id=list li # Link text here /li /ul Just remember to add whatever you want to the item, and not just use add(...). http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/markup/html/list/ListView.html Alex -Opprinnelig melding- Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 18:08 Til: users@wicket.apache.org Emne: How to build a dynamic navigation bar Hello, I want to be able to build a left-side dynamic navigation bar based on user permissions. For example, if the user does not have access to the Prices page, I do not want to show the Prices link on the navigation bar. Also, since the link will point to a Wicket page, it has to be a Wicket link. This is how I would like the NavBar to appear: div id=mainNav ul li Home /li li Prices /li li Contracts /li li Products /li li Transactions /li /ul /div I tried using ListView, but I could not get it to work, as it forces the wicket id of the line items to be all the same. Thanks in advance. -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18592899.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18593941.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to build a dynamic navigation bar
On Tue, Jul 22, 2008 at 09:59:48AM -0700, Edbay wrote: Thanks for the quick reply. Wouldn't this force all links to have the same wicket ids (linkid)? I'd like to be able to have the line items look like this: ul wicket:id=list li # Link01 text here /li li # Link02 text here /li li # Link03 text here /li /ul Well, you would only put in one link line. The ListView repeats the markup for each item in the list. Note that Alexander's example is a little broken, since it would repeat the entire ul for each item, where I think you want to repeat the li. Personally, I would create a Panel class that encapsulates the link, the link text, and perhaps any required images, behaviours, etc. Then I would use a RepeatingView and add as many of these panels as I need: ul !-- note: the a tag here is only for preview, it will be replaced by the link panel contents -- li wicket:id=menuItema href=#Foo/a/li /ul RepeatingView menu = new RepeatingView(menuItem); menu.add(new MyMenuPanel(menu.newChildId(), Home, HomePage.class)); if (userIsDarthVader) { menu.add(new MyMenuPanel(menu.newChildId(), Enslave Universe, EnslaveUniversePage.class)); } jk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to build a dynamic navigation bar
Edbay wrote: I tried using ListView, but I could not get it to work, as it forces the wicket id of the line items to be all the same. Why is that a problem? Using ListView should be a good solution. Could you elaborate? -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18595504.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to build a dynamic navigation bar
Here is my code that works for me. I put the navigation bar in a panel. wicket:panel span wicket:id=mainNavList span wicket:id=navigationItem a href=# span wicket:id=navigationLabel/span /a /span /span /wicket:panel And the java class looks like this: public class MainMenuListView extends ListViewINavigationItem { private static final long serialVersionUID = 1L; protected static Logger logger = Logger.getLogger(MainMenuListView.class); public MainMenuListView(String id, ListINavigationItem dataList) { super(id, dataList); } @Override protected void populateItem(ListItem item) { INavigationItem navItem = (INavigationItem) item.getModelObject(); ResourceModel rModel = new ResourceModel(navItem.getResourceKey()); BookmarkablePageLink pageLink = new BookmarkablePageLink(navigationItem, navItem.getNavTargetClass()); item.add(new BookmarkablePageLink(navigationItem, navItem.getNavTargetClass()).add(new Label(navigationLabel, rModel))); } } Alexander Landsnes Keül wrote: They need the same wicket:id yes, but that doesn't mean that they need the same text or targets. Just create as many links as you want/need, with whatever behaviour they need. Just make sure they all have the same id :) Alex -Opprinnelig melding- Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 19:00 Til: users@wicket.apache.org Emne: RE: How to build a dynamic navigation bar Thanks for the quick reply. Wouldn't this force all links to have the same wicket ids (linkid)? I'd like to be able to have the line items look like this: ul wicket:id=list li # Link01 text here /li li # Link02 text here /li li # Link03 text here /li /ul Alexander Landsnes Keül wrote: I'd use a ListView :) Assuming this lil code add( new ListView(list, linkList ) { public void populateItem(ListItem item) { item.add( (Link)linkList ); } }); You'd have the html look something like this ul wicket:id=list li # Link text here /li /ul Just remember to add whatever you want to the item, and not just use add(...). http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/markup/html/list/ListView.html Alex -Opprinnelig melding- Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 18:08 Til: users@wicket.apache.org Emne: How to build a dynamic navigation bar Hello, I want to be able to build a left-side dynamic navigation bar based on user permissions. For example, if the user does not have access to the Prices page, I do not want to show the Prices link on the navigation bar. Also, since the link will point to a Wicket page, it has to be a Wicket link. This is how I would like the NavBar to appear: div id=mainNav ul li Home /li li Prices /li li Contracts /li li Products /li li Transactions /li /ul /div I tried using ListView, but I could not get it to work, as it forces the wicket id of the line items to be all the same. Thanks in advance. -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18592899.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to build a dynamic navigation bar
I get this approach. Can you provide the code for the panel? ul !-- note: the tag here is only for preview, it will be replaced by the link panel contents -- li wicket:id=menuItem # Foo /li /ul RepeatingView menu = new RepeatingView(menuItem); menu.add(new MyMenuPanel(menu.newChildId(), Home, HomePage.class)); if (userIsDarthVader) { menu.add(new MyMenuPanel(menu.newChildId(), Enslave Universe, EnslaveUniversePage.class)); } -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18598120.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to build a dynamic navigation bar
Something like this... wicket:panel a wicket:id=linkspan wicket:id=labelFoo/span/a /wicket:panel public class MyMenuPanel extends Panel { public MyMenuPanel(String id, String label, Class pageClass) { super(id); Link link = new BookmarkablePageLink(link, pageClass); add(link); link.add(new Label(label, label)); } } jk On Tue, Jul 22, 2008 at 01:32:55PM -0700, Edbay wrote: I get this approach. Can you provide the code for the panel? ul !-- note: the tag here is only for preview, it will be replaced by the link panel contents -- li wicket:id=menuItem # Foo /li /ul RepeatingView menu = new RepeatingView(menuItem); menu.add(new MyMenuPanel(menu.newChildId(), Home, HomePage.class)); if (userIsDarthVader) { menu.add(new MyMenuPanel(menu.newChildId(), Enslave Universe, EnslaveUniversePage.class)); } -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18598120.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to build a dynamic navigation bar
Works! :clap: wicket:panel Foo /wicket:panel public class MyMenuPanel extends Panel { public MyMenuPanel(String id, String label, Class pageClass) { super(id); Link link = new BookmarkablePageLink(link, pageClass); add(link); link.add(new Label(label, label)); } } -- View this message in context: http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18598822.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]