Re: Navigation bar links
See org.apache.wicket.markup.html.link.BookmarkablePageLink#linksTo(Page). if (link.linksTo(getPage()) { link.setEnable(false); } On Tue, Aug 21, 2012 at 7:54 PM, Mansour Al Akeel mansour.alak...@gmail.com wrote: Thank you a lot. Both methods did the trick. One last question in the same context. This is the code I am working with: list.add(new BookmarkablePageLinkWebPage(link, HomePage.class)); list.add(new BookmarkablePageLinkWebPage(link, About.class)); list.add(new BookmarkablePageLinkWebPage(link, ContactUs.class)); @SuppressWarnings(unchecked) ListView listview = new ListView(listview, list) { protected void populateItem(ListItem item) { BookmarkablePageLinkWebPage lnk = (BookmarkablePageLinkWebPage) item .getModelObject(); String requestedUrl = getRequest().getUrl().getPath(); String linkUrl = getRequestCycle().urlFor( lnk.getPageClass() , new PageParameters()).toString().substring(2); logger.debug(requested : + requestedUrl); logger.debug(current link : + linkUrl); Label label = new Label(lbl, lnk.getId()); lnk.add(label); item.add(lnk); if (linkUrl.equals(requestedUrl)) { logger.debug(matched link with requested url); // lnk.setRenderBodyOnly(true); lnk.setEnabled(false); } } }; add(listview); I am trying to compare the requested URL to the link url. I need to obtain the link url. It's no clear to me how to do it in clean way. I am using: String linkUrl = getRequestCycle().urlFor( lnk.getPageClass() , new PageParameters()).toString().substring(2); This introduced a problem. It works fine if the page is mounted on some path. But if the link url is something like: wicket/bookmarkable/com.example.MyPage Then it breaks. Is there a better way to obtain the url for each link ?? Thank you. On Tue, Aug 21, 2012 at 2:55 AM, Martin Grigorov mgrigo...@apache.orgwrote: Or you can do link.setRenderBodyOnly(true); On Tue, Aug 21, 2012 at 9:30 AM, Sven Meier s...@meiers.net wrote: You can use a disabled link, which will render as a span. Sven On 08/21/2012 08:10 AM, Mansour Al Akeel wrote: I am looking to produce the following mark up: ul lia href=/Home/a/li li class=current About/li lia href=contactContact us/a/li ul the problem is I can not add a conditionally to li. I am using ListView to populate the Items. Can someone give me a hint about how to achieve this ?? Thank you in advance. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Navigation bar links
I am looking to produce the following mark up: ul lia href=/Home/a/li li class=current About/li lia href=contactContact us/a/li ul the problem is I can not add a conditionally to li. I am using ListView to populate the Items. Can someone give me a hint about how to achieve this ?? Thank you in advance.
Re: Navigation bar links
You can use a disabled link, which will render as a span. Sven On 08/21/2012 08:10 AM, Mansour Al Akeel wrote: I am looking to produce the following mark up: ul lia href=/Home/a/li li class=current About/li lia href=contactContact us/a/li ul the problem is I can not add a conditionally to li. I am using ListView to populate the Items. Can someone give me a hint about how to achieve this ?? Thank you in advance. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Navigation bar links
Thank you a lot. Both methods did the trick. One last question in the same context. This is the code I am working with: list.add(new BookmarkablePageLinkWebPage(link, HomePage.class)); list.add(new BookmarkablePageLinkWebPage(link, About.class)); list.add(new BookmarkablePageLinkWebPage(link, ContactUs.class)); @SuppressWarnings(unchecked) ListView listview = new ListView(listview, list) { protected void populateItem(ListItem item) { BookmarkablePageLinkWebPage lnk = (BookmarkablePageLinkWebPage) item .getModelObject(); String requestedUrl = getRequest().getUrl().getPath(); String linkUrl = getRequestCycle().urlFor( lnk.getPageClass() , new PageParameters()).toString().substring(2); logger.debug(requested : + requestedUrl); logger.debug(current link : + linkUrl); Label label = new Label(lbl, lnk.getId()); lnk.add(label); item.add(lnk); if (linkUrl.equals(requestedUrl)) { logger.debug(matched link with requested url); // lnk.setRenderBodyOnly(true); lnk.setEnabled(false); } } }; add(listview); I am trying to compare the requested URL to the link url. I need to obtain the link url. It's no clear to me how to do it in clean way. I am using: String linkUrl = getRequestCycle().urlFor( lnk.getPageClass() , new PageParameters()).toString().substring(2); This introduced a problem. It works fine if the page is mounted on some path. But if the link url is something like: wicket/bookmarkable/com.example.MyPage Then it breaks. Is there a better way to obtain the url for each link ?? Thank you. On Tue, Aug 21, 2012 at 2:55 AM, Martin Grigorov mgrigo...@apache.orgwrote: Or you can do link.setRenderBodyOnly(true); On Tue, Aug 21, 2012 at 9:30 AM, Sven Meier s...@meiers.net wrote: You can use a disabled link, which will render as a span. Sven On 08/21/2012 08:10 AM, Mansour Al Akeel wrote: I am looking to produce the following mark up: ul lia href=/Home/a/li li class=current About/li lia href=contactContact us/a/li ul the problem is I can not add a conditionally to li. I am using ListView to populate the Items. Can someone give me a hint about how to achieve this ?? Thank you in advance. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
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]
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]
Navigation bar
Hi, I need your help. After few days I am out of ideas and still have no solution. What I have: I have stored users in databes and each user has some List od favourite pages URLs. This URLs links external pages. What I need: I need to do some sort of TabbedPanel or one row table without headers, which will contains links to the stored URLs. Where is the problem: First I try to use TabbedPanel but this is impossible due to the TabbedPanel returns just wicket Panel and not any URL. Then I try to use DataTable but these tables have header line. So I try to give my links to the headers. It looks like it is working. But it did not render to the page. I think it was due to empty data rows so wicket does not render the empty table. At last I try to use GridView but I was not able to determine the names of url links. Please have you met this problem before? Is it possible to upgrade the TabbedPanel to return the url instead of Panel?? Thanks for any advice. Milan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Navigation bar
add(new listview(links, linksmodel) { onpopulateitem(item item) { e=new externallink(link, item.getmodel().getlink(), item.getmodel().getlabel()); } } tabletrtd wicket:id=linksa wicket:id=linklink/a/td/tr/table -igor On Mon, Apr 7, 2008 at 3:44 AM, Milan Křápek [EMAIL PROTECTED] wrote: Hi, I need your help. After few days I am out of ideas and still have no solution. What I have: I have stored users in databes and each user has some List od favourite pages URLs. This URLs links external pages. What I need: I need to do some sort of TabbedPanel or one row table without headers, which will contains links to the stored URLs. Where is the problem: First I try to use TabbedPanel but this is impossible due to the TabbedPanel returns just wicket Panel and not any URL. Then I try to use DataTable but these tables have header line. So I try to give my links to the headers. It looks like it is working. But it did not render to the page. I think it was due to empty data rows so wicket does not render the empty table. At last I try to use GridView but I was not able to determine the names of url links. Please have you met this problem before? Is it possible to upgrade the TabbedPanel to return the url instead of Panel?? Thanks for any advice. Milan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Navigation bar
Thanks a lot, this was the thing I was looking for. Milan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]