Problem with menu state

Post Reply
FkJ
Posts: 183
Joined: 08 Jan 2010, 19:16

13 Jun 2018, 19:37

I'm replacing the redmond theme of an existing application with omega theme + layout. I noticed that the menu state is not working correctly. Sometimes it doesn't highlights anything, sometimes it highlights the wrong item and sometimes it highlights more than one item.

I took a look at layout.js, but I was not able to figure out what is going on.

http://54.94.142.248/cliente1977

Could you please take a look? Username 1, password test

Test case: navigate to Consultas > Senhas, the menu state is saved correctly. After navigate to Consultas > Solicitações, the menu item "Comunicados" is highlighted.

Thanks in advance

User avatar
aragorn
Posts: 3619
Joined: 29 Jun 2013, 12:38

18 Jun 2018, 08:26

Thanks for the sample. Do menuitems have the unique ids on your menu?

FkJ
Posts: 183
Joined: 08 Jan 2010, 19:16

20 Jun 2018, 15:39

Adding fixed ids solves the issue.

As a suggestion for enhancement, on layout.js you could replace {path: '/'} with {path: '<<context path from jsf>>'}. I have more than one webapp with omega on the same server, so when I reset the menu state for one it affects the other. I could simply edit layout.js, but I prefer keeping the layout files original for an easier upgrade if a new version is available.

Thanks

User avatar
aragorn
Posts: 3619
Joined: 29 Jun 2013, 12:38

06 Jul 2018, 10:27

Glad to hear, thanks a lot for the update! I think you can override layout.js. My example code for you;

Code: Select all

//template.xhtml
<script id="layoutScriptId" type="text/javascript" src="#{request.contextPath}/resources/ultima-layout/js/layout.js" data-contextPath="#{request.contextPath}" />

//layout.js
init: function(cfg) {
   ..
   this.path = $('#layoutScriptId').attr('data-contextPath');
}

...

saveMenuState: function() {
        $.cookie('ultima_expandeditems', this.expandedMenuitems.join(','), {path: this.path});
},
    
clearMenuState: function() {
        $.removeCookie('ultima_expandeditems', {path: this.path});
},
    
setInlineProfileState: function(expanded) {
        if(expanded)
            $.cookie('ultima_inlineprofile_expanded', "1", {path: this.path});
        else
            $.removeCookie('ultima_inlineprofile_expanded', {path: this.path});
},
Best Regards,

Post Reply

Return to “Omega - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest