I have a static menu in the sidebar which I include in every JSF page. The menu looks like so:
<li class="nav-header">Item 1</li>
<li class="active"><a href="index.xhtml">Item 2</a></li>
<li><a href="new_workload.xhtml">Item 3</a></li>
<li><a href="import_workload.xhtml">Item 4</a></li>
Adding a class="active" to the <li> highlights the menu. How do I go about making sure selected item is highlighted dynamically in JSF2?
I know PrimeFaces and RichFaces have ready made components for this, but I want to try a pure JSF 2 solution first. A pure client side JavaScript solution is also acceptable.
You can get the current view ID in EL as follows
So, this should do
It’d be easier to hold all those links in some
List<Page>so that you can just do something likeinstead of copypasting the same piece of code over and over.