Spark menu not working with PF 6.2

Post Reply
Dsleeper
Posts: 109
Joined: 29 Jul 2010, 13:33
Location: Bergen, Norway
Contact:

03 Mar 2018, 17:13

Hi,

The Spark menus are not working after I have upgraded my project to Primefaces 6.2. The topmenu is rendered, but no dropdown elements are triggered on mouse click.

Is this something that can be easily fixed in the "layout.js" of Spark? I really would like to use the new 6.2 support for primefaces.MOVE_SCRIPTS_TO_BOTTOM :)

Chrome console log:
layout.js.jsf?ln=spark-layout:19 Uncaught TypeError: topmenuItems.size is not a function
at c.init (http://localhost:8080/javax.faces.resou ... yout:19:37)
at c.e.(anonymous function) [as init] (http://localhost:8080/javax.faces.resou ... =6.2:5:335)
at new c (http://localhost:8080/javax.faces.resou ... =6.2:5:437)
at Object.createWidget (http://localhost:8080/javax.faces.resou ... 6.2:1:4964)
at Object.cw (http://localhost:8080/javax.faces.resou ... 6.2:1:4785)
at http://localhost:8080/forum/topic/523:186:4
init @ layout.js.jsf?ln=spark-layout:19
e.(anonymous function) @ core.js.jsf?ln=primefaces&v=6.2:5
c @ core.js.jsf?ln=primefaces&v=6.2:5
createWidget @ core.js.jsf?ln=primefaces&v=6.2:1
cw @ core.js.jsf?ln=primefaces&v=6.2:1
(anonymous) @ 523:186
Primefaces, Mojarra, Tomcat

http://www.dsleeper.net
http://www.mylog.no

Dsleeper
Posts: 109
Joined: 29 Jul 2010, 13:33
Location: Bergen, Norway
Contact:

03 Mar 2018, 20:53

Fixed this by doing the following:
1. Open your Spark layout.js (\src\main\webapp\resources\spark-layout\js\
2. Change line 19 from:

Code: Select all

        for(var i=0; i<topmenuItems.size(); i++) {
to

Code: Select all

        for(var i=0; i<topmenuItems.length; i++) {
I guess this error occurred because PF 6.2 upgraded to the latest JQuery implementation. In the latest JQuery ".size()" has removed in favor for ".length"

If possible this should probably be put into a Spark patch?
Primefaces, Mojarra, Tomcat

http://www.dsleeper.net
http://www.mylog.no

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

07 Mar 2018, 08:41

Thanks a lot for the PR, please use the following code for now;

Code: Select all

/** 
 * PrimeFaces Spark Layout
 */
PrimeFaces.widget.Spark = PrimeFaces.widget.Spark.extend({
  
    init: function(cfg) {
        this._super(cfg);
        this.menubar = $('#layout-menu');
        this.topmenu = $('#layout-topbar-menu');
        this.menumask = $('#menu-mask');
        this.focusedLink = null;
        this.focusedTopLink = null;
        this.layoutMenuClick = false;
        this.topbarMenuClick = false;
        
        // for keyboard navigation
        this.topmenu.attr('tabindex', '0');
        var topmenuItems = this.topmenu.find('a');
        for(var i=0; i<topmenuItems.length; i++) {
            topmenuItems.eq(i).attr('tabindex', '-1');
        } 
        
        this.bindEvents();
        this.bindKeyEvents();
    }
});
If possible this should probably be put into a Spark patch?
Could you please send an email to contact at primetek.com.tr?

Dsleeper
Posts: 109
Joined: 29 Jul 2010, 13:33
Location: Bergen, Norway
Contact:

07 Mar 2018, 09:17

Email sent! :geek:
Primefaces, Mojarra, Tomcat

http://www.dsleeper.net
http://www.mylog.no

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

12 Mar 2018, 14:23

Thanks a lot!

jcpearce2005
Posts: 16
Joined: 06 Feb 2015, 20:34

15 Mar 2018, 16:07

This had been stumping me for a bit.

Thank you for the fix!

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

26 Mar 2018, 13:29

Thanks a lot for the update! ;)

asesovici
Posts: 7
Joined: 13 Mar 2018, 16:35

19 Apr 2018, 15:57

Hi @aragorn, I am having the same problem after upgrading to PrimeFaces 6.2.

I am currently using Spark Layout v2.1.1. I see on PrimeStore that v2.1.2 is available and it appears that its layout.js is using the new function you mentioned. Should I try to use v2.1.2 instead? Is it fully compatible with PF 6.2?
If so, then what I don't understand is why the Migration Update from v.2.1.1 to 2.1.2 doesn't mention anything about updating the layout.js file.

Thank you in advance.
PrimeFaces 6.2 | JSF 2.2 | Glassfish 4.1.1

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest