Poseidon Set active Menu Item

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
BLan
Posts: 1
Joined: 07 Dec 2016, 08:33

17 May 2017, 10:26

Hello,
is there a way to set the current active Menu Item in Code.
I do navigation via navigation-rules and would like to adjust the selected Menu Item based on the current page.

I tried this approach: http://blog.awolski.com/keeping-a-prime ... em-active/
but since the Menu-Component in Poseidon is a special component included in the theme, this approach did not work out for me.

I would be thankful for any suggestions on how i can set the active menu item of the PoseidonMenu-Component via code.

Kind regards,

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

17 May 2017, 14:57

We use jquery cookie for stateful feature on Poseidon menu. I think you can use it. You need to add id of active menu item into cookie. Exp;

Code: Select all

<script type="text/javascript">
    function testFunc() {
        var $this = PF('me');

        if($this) {
            /* clear state */
            $this.expandedMenuitems = [];
            $this.deactivateItems($this.menu.find('li.active-menuitem'));

            $this.addMenuitem('menuform:om_doc');
            $this.restoreMenuState();
        }

    }
</script>

//menu.xHtML
<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:pp="http://primefaces.org/poseidon">
     
    <h:form id="menuform">
        ...
                    <pp:menu widgetVar="me">
                        ...
                        <p:menuitem id="om_doc" value="Documentation" icon="fa fa-fw fa-book" outcome="/docs"/>
                    </pp:menu>
                    
         ...
    </h:form>
</ui:composition>

Code: Select all

//forms.xhtml
<p:commandButton value="Docs" action="docs.xhtml" oncomplete="testFunc();"/>

Post Reply

Return to “Poseidon - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests