ckeditor not loading because of JavaScript error

Community Driven Extensions Project
Post Reply
henrik.n
Posts: 4
Joined: 29 Aug 2019, 17:40

06 Nov 2020, 13:24

I'm trying to replace p:editor by pe:ckeditor, but I'm getiing the following JavaScript error

Code: Select all

primefaces-extensions.js.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?ln=primefaces-extensions&v=6.2.11:formatted:11 Uncaught TypeError: Cannot read property '1' of null
    at Object.getFacesResource (primefaces-extensions.js.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?ln=primefaces-extensions&v=6.2.11:formatted:11)
    at c.init (primefaces-extensions.js.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?ln=primefaces-extensions&v=6.2.11:formatted:142)
    at c.e.<computed> [as init] (core.js.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?ln=primefaces&v=6.2:5)
    at new c (core.js.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?ln=primefaces&v=6.2:5)
    at Object.createWidget (core.js.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?ln=primefaces&v=6.2:1)
    at Object.cw (core.js.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?ln=primefaces&v=6.2:1)
    at mailTemplate.xhtml;jsessionid=89C563BBC7FD42E5EFD18A78B44B1B4F?dswid=-9162:105
The method looks like this in the browser:

Code: Select all

getFacesResource: function(a, b, d) {
        0 === a.indexOf("/") && (a = a.substring(1, a.length));
        var c = PrimeFacesExt.getResourceScriptURI()
          , f = PrimeFacesExt.getResourceScriptName(c);
        c = c.replace(f, a);
        f = "ln\x3d" + /[?&]([^&=]*)ln=(.*?)(&|$)/.exec(c)[2];
        a = "";
        -1 < c.indexOf("?" + f) || -1 < c.indexOf("\x26" + f) || (a = (new RegExp("[?\x26]([^\x26\x3d]+)" + f + "($|\x26)")).exec(c)[1]);
        c = c.replace(a + f, a + "ln\x3d" + b);
        d && (b = (new RegExp("[?\x26]" + a + "v\x3d([^\x26]*)")).exec(c)[1],
        c = c.replace(a + "v\x3d" + b, a + "v\x3d" + d));
        d = window.location.protocol + "//" + window.location.host;
        return 0 <= c.indexOf(d) ? c : d + c
    }
The code fails at line starting with "d &&", because the RegEx doesn't match. When I debug the method, I can see the following variables passed in:

Code: Select all

a = "/ckeditor/ckeditor.js", b = "primefaces-extensions", d = "6.2.11"
c evaluates to "/PORTAL/javax.faces.resource/ckeditor/ckeditor.js.xhtml?ln=bsf"
The URL in c does not contain the version parameter v, which is expected by the RegEx. So my guess is, that it has to do with resource loading and resource versioning, but I don't know nothing about that. In the HTML source I can see, that some JSF resources have the version parameter and some don't. I'm also confused by the ln=bsf, which I guess is the library name for bootsfaces. Shouldn't the URL have ln=primefaces-extensions? (That part gets replaced by the method anyway, so I guess, that was a known problem before)

Any ideas how I can fix this? Can I force JSF to append version numbers somehow?

This happens with:
Primefaces 6.2
Primefaces Extensions 6.2.11
Bootsfaces 1.1.3
Tomcat 9

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

06 Nov 2020, 14:06

I have a feeling Bootsfaces is causing this issue because of the ln=bsf without the version that they have a ResourceHandler stripping off what PF/PFE are adding to URLs.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

henrik.n
Posts: 4
Joined: 29 Aug 2019, 17:40

09 Nov 2020, 12:01

Thanks for your response. Do you have any idea how I can fix the problem? Unfortunately removing bootsfaces is not an option, because it is used all over the project. Maybe something like writing our own ResourceHandler to the counter bootsfaces ResourceHandler?

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

09 Nov 2020, 15:15

I don't work with BootsFaces so I suggest you report an issue on the BootsFaces Issue page on GitHub with a reproducible Test case.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

henrik.n
Posts: 4
Joined: 29 Aug 2019, 17:40

09 Nov 2020, 17:49

Just to confirm my initial assumption: I now removed the bootsfaces maven dependency and all uses of their tags and the editor loads fine.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

09 Nov 2020, 17:51

OK that is good. Now you should be able to report to BootsFaces. their resourcehandler is somehow messing up CKEditor's URL's.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests