Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I hide a menu item with an <li> tag in XPages

Tags:

xpages

I have a traditional menu that us based on this convention

<ul>
<li><xp:link>menu link 1</xp:menulink></li>
<li><xp:menulink>menu link 2</xp:menulink></li>
</ul>

I want to selectively render the menu link 2 based on some logic. I can render the <xp:link> fine but as the <li> is a HTML tag rather than an XPages Tag the rendering cannot be controlled.

I noticed that there is a tagName property for <xp:text> but not for <xp:link>. see : http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=4EB7314545EE0C19852578CB0066CE4C

What is the easiest way to manage this without using repeats etc ?

like image 306
Sean Cull Avatar asked Dec 12 '25 06:12

Sean Cull


1 Answers

You can also wrap the entire <li>...</li> tag in an <xp:panel> tag that has a rendered script on it. Don't give the xp:panel an ID and no extra code is sent to the browser.

If you are using the Extlib or UP1 then you can also use the <xe:listcontainer> tag. It renders each direct child entry as a list item so you would end up with code similar to..

<xe:listcontainer>
  <xp:link> ... </xp:link>
  <xp:link rendered="renderscript"> ... </xp:link>
  <xp:link> ... </xp:link>
</xe:listcontainer>

In this case there is no need for you to add the <ul> or <li> tags in the code, the ExtLib will look after that for you.

like image 160
Declan Lynch Avatar answered Dec 16 '25 01:12

Declan Lynch