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 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 BookmarkablePageLink("link", HomePage.class)); > list.add(new BookmarkablePageLink("link", About.class)); > list.add(new BookmarkablePageLink("link", > ContactUs.class)); > > @SuppressWarnings("unchecked") > ListView listview = new ListView("listview", list) { > protected void populateItem(ListItem item) { > > BookmarkablePageLink lnk = > (BookmarkablePageLink) 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 wrote: > >> Or you can do link.setRenderBodyOnly(true); >> >> On Tue, Aug 21, 2012 at 9:30 AM, Sven Meier wrote: >> > You can use a disabled link, which will render as a . >> > >> > Sven >> > >> > >> > On 08/21/2012 08:10 AM, Mansour Al Akeel wrote: >> >> >> >> I am looking to produce the following mark up: >> >> >> >> Home >> >> About >> >> 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
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 BookmarkablePageLink("link", HomePage.class)); list.add(new BookmarkablePageLink("link", About.class)); list.add(new BookmarkablePageLink("link", ContactUs.class)); @SuppressWarnings("unchecked") ListView listview = new ListView("listview", list) { protected void populateItem(ListItem item) { BookmarkablePageLink lnk = (BookmarkablePageLink) 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 wrote: > Or you can do link.setRenderBodyOnly(true); > > On Tue, Aug 21, 2012 at 9:30 AM, Sven Meier wrote: > > You can use a disabled link, which will render as a . > > > > Sven > > > > > > On 08/21/2012 08:10 AM, Mansour Al Akeel wrote: > >> > >> I am looking to produce the following mark up: > >> > >> Home > >> About > >> http://jWeekend.com > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: Navigation bar links
Or you can do link.setRenderBodyOnly(true); On Tue, Aug 21, 2012 at 9:30 AM, Sven Meier wrote: > You can use a disabled link, which will render as a . > > Sven > > > On 08/21/2012 08:10 AM, Mansour Al Akeel wrote: >> >> I am looking to produce the following mark up: >> >> Home >> About >> http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Navigation bar links
You can use a disabled link, which will render as a . Sven On 08/21/2012 08:10 AM, Mansour Al Akeel wrote: I am looking to produce the following mark up: Home About - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org