This is how my menu is working ATM (on JSF 2.2 and PrimeFaces 13.0.5)
<p:menuitem value="My menu item" outcome="/some-view-id"
styleClass="#{currentView.isView('some-view-id') ? 'selected':''}" />
Notice i pass viewId 'manualy' to determine styleClass.
I would like to make 'generic' method, something like
<p:menuitem value="My menu item" outcome="/some-view-id"
styleClass="#{currentView.isView(component.outcome) ? 'selected':''}" />
but this is not working! #{component}
is referring to <p:menu>
and not <p:menuItem>
.
Using binding is working but i achieved nothing since i have to declare it for each menuItem.
<p:menuitem value="My menu item" outcome="/some-view-id"
binding="#{myMenuItemBinding}"
styleClass="#{currentView.isView(myMenuItemBinding.outcome) ? 'selected':''}" />
Any ideas? I was expecting #{component}
to be <p:menuItem>
...
Edit: Fixed in PrimeFaces 13.0.6
This was reported on GitHub and fixed in 13.0.6.
Issue: https://github.com/primefaces/primefaces/issues/11358