Re: Navigation bar links

2012-08-22 Thread Martin Grigorov
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

2012-08-21 Thread Mansour Al Akeel
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

2012-08-21 Thread Sven Meier

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

2012-08-21 Thread Mansour Al Akeel
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