TheCoder4eu / BootsFaces-OSP

BootsFaces - Open Source Project
Apache License 2.0
247 stars 102 forks source link

Help request - CKeditor from primefaces-extensions does not load with Bootsfaces #1157

Closed hampelratte closed 1 week ago

hampelratte commented 3 years ago

I'm using Bootsfaces together with Primefaces and I'm currently trying to replace Primefaces p:editor by pe:ckeditor, but I'm getting the following JavaScript error

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:

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:

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. 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)

If I remove Bootsfaces from the project, the editor loads fine. Any ideas how I can fix this?

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

stephanrauh commented 1 week ago

I'm afraid development of BootsFaces has slowed down considerably. We'll never manage to address this issue. Let's close it.