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 BookmarkablePageLink<WebPage>("link", HomePage.class)); > list.add(new BookmarkablePageLink<WebPage>("link", About.class)); > list.add(new BookmarkablePageLink<WebPage>("link", > ContactUs.class)); > > @SuppressWarnings("unchecked") > ListView listview = new ListView("listview", list) { > protected void populateItem(ListItem item) { > > BookmarkablePageLink<WebPage> lnk = > (BookmarkablePageLink<WebPage>) 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.org>wrote: > >> 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> >> >> <li><a href="/">Home</a></li> >> >> <li class="current"> About</li> >> >> <li><a href="contact>Contact 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