TheCoder4eu / BootsFaces-OSP

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

DataTable onSelect works but generates javascript "network error" #1164

Closed jscrump59 closed 3 years ago

jscrump59 commented 3 years ago

The datatable does execute onselect="ajax:mainfeed.onSelect(feed,typeOfSelection,indexes) and works properly, but it immediately displays a "network error" dialog three times.

I switched from Developer mode to Production which clears up the problem, but inspecting the table lists several errors concerning "Reason: missing token ‘xyz’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel". It's defined at https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMissingAllowHeaderFromPreflight .

This is an example of one of the errors:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cdn.datatables.net/v/bs/jszip-2.5.0/dt-1.10.20/af-2.3.4/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/rr-1.2.6/sc-2.0.1/sl-1.3.1/datatables.min.js. (Reason: header ‘content-type’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response).

This is different type of error.

XML Parsing Error: not well-formed Location: http://localhost:8080/chronicle/pages/javax.faces.resource/jq/ui/i18n/dt/datatable-en.json?ln=bsf Line Number 1, Column 1: datatable-en.json:1:1

{
    "sEmptyTable":     "No data available in table",
    "sInfo":           "Showing _START_ to _END_ of _TOTAL_ entries",
    "sInfoEmpty":      "Showing 0 to 0 of 0 entries",
    "sInfoFiltered":   "(filtered from _MAX_ total entries)",
    "sInfoPostFix":    "",
    "sInfoThousands":  ",",
    "sLengthMenu":     "Show _MENU_ entries",
    "sLoadingRecords": "Loading...",
    "sProcessing":     "Processing...",
    "sSearch":         "Search:",
    "sZeroRecords":    "No matching records found",
    "oPaginate": {
        "sFirst":    "First",
        "sLast":     "Last",
        "sNext":     "Next",
        "sPrevious": "Previous"
    },
    "oAria": {
        "sSortAscending":  ": activate to sort column ascending",
        "sSortDescending": ": activate to sort column descending"
    }
}

Can you see what I might be doing wrong?

Thanks

macbl commented 3 years ago

I've got a similar problem on Tomee Webprofile & Micropofile (MyFaces) - Tomee PLUME with Mojarra however works. As fare as I unserstand it only occurs on AJAX request (datatable select). The AJAX request somehow includes the Access-Control-Allow-Origin: https://localhost:8443 which prevets accessing the other datatables scripts.

I also played with the CORS filter settings, no luck with that. Any Idea how to make datatables select working?

(I can confirm that Datatables selection works in production mode:

 <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
jscrump59 commented 3 years ago

I don't have a fix, but a work around is Production in web.xmlI'm using tomee too.On Feb 8, 2021 2:06 AM, macbl notifications@github.com wrote: I've got a similar problem on Tomee Webprofile & Micropofile (MyFaces) - Tomee PLUME with Mojarra however works. As fare as I unserstand it only occurs on AJAX request (datatable select). The AJAX request somehow includes the Access-Control-Allow-Origin: https://localhost:8443 which prevets accessing the other datatables scripts. I also played with the CORS filter settings, no luck with that. Any Idea how to make datatables select working?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.

macbl commented 3 years ago

Turing on production mode in web.xml basically seems to supress the javascript warnings, when looking into the browser console you can see, that the CORS errors are still there. I can confirm that no errors exist on TOMEE PLUME 8.0.6 which is using Mojarra as JSF implementation. So the problem might might have something to do with the MyFaces configuration?

jscrump59 commented 3 years ago

I'm using tomee-8.0.4-webprofile. This is my web.xml:

    <context-param>
        <param-name>BootsFaces_USETHEME</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>BootsFaces_THEME</param-name>
        <param-value>cerulean</param-value>
    </context-param>
    <!-- Activates the waitcursor and the double-click protection -->
    <context-param>
        <param-name>net.bootsfaces.blockUI</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.FACELETS_REFRESH_PERIOD</param-name>
        <param-value>-1</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.PARTIAL_STATE_SAVING_METHOD</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.CACHE_EL_EXPRESSIONS</param-name>
        <param-value>alwaysRecompile</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.USE_ENCRYPTION</param-name>
        <param-value>true</param-value>
    </context-param>

Does anything look out of order?


From: macbl notifications@github.com Sent: Tuesday, February 9, 2021 3:16 AM To: TheCoder4eu/BootsFaces-OSP BootsFaces-OSP@noreply.github.com Cc: jeff.crump crumptech.com jeff.crump@crumptech.com; Author author@noreply.github.com Subject: Re: [TheCoder4eu/BootsFaces-OSP] DataTable onSelect works but generates javascript "network error" (#1164)

Turing on production mode in web.xml basically seems to supress the javascript warnings, when looking into the browser console you can see, that the CORS errors are still there. I can confirm that no errors exist on TOMEE PLUME 8.0.6 which is using Mojarra as JSF implementation. So the problem might might have something to do with the MyFaces configuration?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/TheCoder4eu/BootsFaces-OSP/issues/1164#issuecomment-775788139, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC2DNJMJJRDMVDBQ2D4ATUDS6D4NFANCNFSM4W7V3O6Q.

macbl commented 3 years ago

This is getting really paniful. I realize that selection is not properly working - not even in Production mode. Isn't there any way to fix the root cause of this problem? Any MyFaces experts here? My application makes heavy use of table selections, but most table selection AJAX calls are not working any more..

jsf.js?ln=javax.faces:1 Access to XMLHttpRequest at 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js' from origin 'https://localhost:8443' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
loadScriptEval @ jsf.js?ln=javax.faces:1
B @ jsf.js?ln=javax.faces:1
runScripts @ jsf.js?ln=javax.faces:1
_eval @ jsf.js?ln=javax.faces:1
insertAfter @ jsf.js?ln=javax.faces:1
_addResourceToHead @ jsf.js?ln=javax.faces:1
processUpdate @ jsf.js?ln=javax.faces:1
processChanges @ jsf.js?ln=javax.faces:1
processResponse @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
onsuccess @ jsf.js?ln=javax.faces:1
(anonym) @ jsf.js?ln=javax.faces:1
load (asynchron)
mixMaps @ jsf.js?ln=javax.faces:1
send @ jsf.js?ln=javax.faces:1
enqueue @ jsf.js?ln=javax.faces:1
xhrQueuedPost @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
BsF.ajax.callAjax @ bsf.js?ln=bsf:24
(anonym) @ adminAsset.xhtml:26
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
(anonym) @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
m @ datatables.min.js:699
(anonym) @ datatables.min.js:711
iterator @ datatables.min.js:140
(anonym) @ datatables.min.js:711
(anonym) @ datatables.min.js:144
(anonym) @ datatables.min.js:143
w @ datatables.min.js:704
(anonym) @ datatables.min.js:698
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
jsf.js?ln=javax.faces:1 GET https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js net::ERR_FAILED
loadScriptEval @ jsf.js?ln=javax.faces:1
B @ jsf.js?ln=javax.faces:1
runScripts @ jsf.js?ln=javax.faces:1
_eval @ jsf.js?ln=javax.faces:1
insertAfter @ jsf.js?ln=javax.faces:1
_addResourceToHead @ jsf.js?ln=javax.faces:1
processUpdate @ jsf.js?ln=javax.faces:1
processChanges @ jsf.js?ln=javax.faces:1
processResponse @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
onsuccess @ jsf.js?ln=javax.faces:1
(anonym) @ jsf.js?ln=javax.faces:1
load (asynchron)
mixMaps @ jsf.js?ln=javax.faces:1
send @ jsf.js?ln=javax.faces:1
enqueue @ jsf.js?ln=javax.faces:1
xhrQueuedPost @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
BsF.ajax.callAjax @ bsf.js?ln=bsf:24
(anonym) @ adminAsset.xhtml:26
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
(anonym) @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
m @ datatables.min.js:699
(anonym) @ datatables.min.js:711
iterator @ datatables.min.js:140
(anonym) @ datatables.min.js:711
(anonym) @ datatables.min.js:144
(anonym) @ datatables.min.js:143
w @ datatables.min.js:704
(anonym) @ datatables.min.js:698
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
jsf.js?ln=javax.faces:1 Access to XMLHttpRequest at 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js' from origin 'https://localhost:8443' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
loadScriptEval @ jsf.js?ln=javax.faces:1
B @ jsf.js?ln=javax.faces:1
runScripts @ jsf.js?ln=javax.faces:1
_eval @ jsf.js?ln=javax.faces:1
insertAfter @ jsf.js?ln=javax.faces:1
_addResourceToHead @ jsf.js?ln=javax.faces:1
processUpdate @ jsf.js?ln=javax.faces:1
processChanges @ jsf.js?ln=javax.faces:1
processResponse @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
onsuccess @ jsf.js?ln=javax.faces:1
(anonym) @ jsf.js?ln=javax.faces:1
load (asynchron)
mixMaps @ jsf.js?ln=javax.faces:1
send @ jsf.js?ln=javax.faces:1
enqueue @ jsf.js?ln=javax.faces:1
xhrQueuedPost @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
BsF.ajax.callAjax @ bsf.js?ln=bsf:24
(anonym) @ adminAsset.xhtml:26
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
(anonym) @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
m @ datatables.min.js:699
(anonym) @ datatables.min.js:711
iterator @ datatables.min.js:140
(anonym) @ datatables.min.js:711
(anonym) @ datatables.min.js:144
(anonym) @ datatables.min.js:143
w @ datatables.min.js:704
(anonym) @ datatables.min.js:698
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
jsf.js?ln=javax.faces:1 GET https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js net::ERR_FAILED
loadScriptEval @ jsf.js?ln=javax.faces:1
B @ jsf.js?ln=javax.faces:1
runScripts @ jsf.js?ln=javax.faces:1
_eval @ jsf.js?ln=javax.faces:1
insertAfter @ jsf.js?ln=javax.faces:1
_addResourceToHead @ jsf.js?ln=javax.faces:1
processUpdate @ jsf.js?ln=javax.faces:1
processChanges @ jsf.js?ln=javax.faces:1
processResponse @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
onsuccess @ jsf.js?ln=javax.faces:1
(anonym) @ jsf.js?ln=javax.faces:1
load (asynchron)
mixMaps @ jsf.js?ln=javax.faces:1
send @ jsf.js?ln=javax.faces:1
enqueue @ jsf.js?ln=javax.faces:1
xhrQueuedPost @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
BsF.ajax.callAjax @ bsf.js?ln=bsf:24
(anonym) @ adminAsset.xhtml:26
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
(anonym) @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
m @ datatables.min.js:699
(anonym) @ datatables.min.js:711
iterator @ datatables.min.js:140
(anonym) @ datatables.min.js:711
(anonym) @ datatables.min.js:144
(anonym) @ datatables.min.js:143
w @ datatables.min.js:704
(anonym) @ datatables.min.js:698
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
jsf.js?ln=javax.faces:1 Access to XMLHttpRequest at 'https://cdn.datatables.net/v/bs/jszip-2.5.0/dt-1.10.20/af-2.3.4/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/rr-1.2.6/sc-2.0.1/sl-1.3.1/datatables.min.js' from origin 'https://localhost:8443' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
loadScriptEval @ jsf.js?ln=javax.faces:1
B @ jsf.js?ln=javax.faces:1
runScripts @ jsf.js?ln=javax.faces:1
_eval @ jsf.js?ln=javax.faces:1
insertAfter @ jsf.js?ln=javax.faces:1
_addResourceToHead @ jsf.js?ln=javax.faces:1
processUpdate @ jsf.js?ln=javax.faces:1
processChanges @ jsf.js?ln=javax.faces:1
processResponse @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
response @ jsf.js?ln=javax.faces:1
onsuccess @ jsf.js?ln=javax.faces:1
(anonym) @ jsf.js?ln=javax.faces:1
load (asynchron)
mixMaps @ jsf.js?ln=javax.faces:1
send @ jsf.js?ln=javax.faces:1
enqueue @ jsf.js?ln=javax.faces:1
xhrQueuedPost @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
request @ jsf.js?ln=javax.faces:1
BsF.ajax.callAjax @ bsf.js?ln=bsf:24
(anonym) @ adminAsset.xhtml:26
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
(anonym) @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
each @ jquery.js?ln=bsf:2
trigger @ jquery.js?ln=bsf:2
m @ datatables.min.js:699
(anonym) @ datatables.min.js:711
iterator @ datatables.min.js:140
(anonym) @ datatables.min.js:711
(anonym) @ datatables.min.js:144
(anonym) @ datatables.min.js:143
w @ datatables.min.js:704
(anonym) @ datatables.min.js:698
dispatch @ jquery.js?ln=bsf:2
v.handle @ jquery.js?ln=bsf:2
jsf.js?ln=javax.faces:1 GET https://cdn.datatables.net/v/bs/jszip-2.5.0/dt-1.10.20/af-2.3.4/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/rr-1.2.6/sc-2.0.1/sl-1.3.1/datatables.min.js net::ERR_FAILED
macbl commented 3 years ago

New tests with a almost blank project proove that there seems to be a major problem between Bootsfaces, datable an MyFaces. Actually any b:datatable insinde a page will kill all ajax calls even when performed outside the table. This is true, even when the table in not set to select mode. For whatever reason even ajax calls in commandLinks outside the table fire requests to https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js. and https://cdn.datatables.net/v/bs/jszip-2.5.0/dt-1.10.20/af-2.3.4/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/rr-1.2.6/sc-2.0.1/sl-1.3.1/datatables.min.js. Is nobody else experiencing problems with this?

macbl commented 3 years ago

I have given up - Datatables in Bootsfaces are currently incompatible with MyFaces. I had to return to TomEE PLUME to keep my application running.

kvj2020 commented 3 years ago

I have had the same experience - CORS errors and javascript network error messages. I use a few BootsFaces datatables and lots of ajax. I could not resolve these issues while using MyFaces in Tomee 8.0.5 and BootsFaces 1.5.0. I solved the issue by removing the apache MyFaces implementation and adding the Oracle Mojarra 2.3 implementation. This is not a great solution but I am past the issue.

jscrump59 commented 3 years ago

Thanks I'll give that a try. I appreciate your suggestion.On Mar 2, 2021 2:08 PM, KevinJ notifications@github.com wrote: I have had the same experience - CORS errors and javascript network error messages. I use a few BootsFaces datatables and lots of ajax. I could not resolve these issues while using MyFaces in Tomee 8.0.5 and BootsFaces 1.5.0. I solved the issue by removing the apache MyFaces implementation and adding the Oracle Mojarra 2.3 implementation. This is not a great solution but I am past the issue.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.

exabrial commented 3 years ago

Would a possible patch would be to load these Javascript files as resources rather than from a CDN?

exabrial commented 3 years ago

So I took a look at this. Let me explain my debug process and maybe this will help people solve their own issues too :)

First, I forked the project and checked everything out. I launched Safari Inspector and loaded the page and noted the name of the scripts that were causing problems. I then cd'd into the bootsfaces dir and executed a grep -ri "datatables.min.js" . and found this reference:

./src/main/java/net/bootsfaces/component/dataTable/DataTable.java:      AddResourcesListener.addDatatablesResourceIfNecessary("https://cdn.datatables.net/v/bs/jszip-2.5.0/dt-1.10.18/af-2.3.2/b-1.5.4/b-colvis-1.5.4/b-html5-1.5.4/b-print-1.5.4/fc-3.2.5/fh-3.1.4/r-2.2.2/rr-1.2.4/sc-1.5.0/sl-1.2.6/datatables.min.js", "js");

Pulling up that source file it calls AddResourcesListener.addDatatablesResourceIfNecessary, which then has a branch for the following: boolean loadDatatables = shouldLibraryBeLoaded(P_GET_DATATABLE_FROM_CDN, true);. So there's actually already a workaround built into the framework! Looking up that constant in C.java you get public static final String P_GET_DATATABLE_FROM_CDN = "net.bootsfaces.get_datatable_from_cdn";. I set that to false in my web.xml and my problem was solved :)

exabrial commented 3 years ago

That being said, I think there's still a bug: pdfmake.min.js is still loaded from the CDN.

    public DataTable() {
        setRendererType(DEFAULT_RENDERER);
        Tooltip.addResourceFiles();
        AddResourcesListener.addThemedCSSResource("core.css");
        // DataTables with almost all extensions except Flash export and KeyTable - version of 10.11.2019
        AddResourcesListener.addDatatablesResourceIfNecessary("https://cdn.datatables.net/v/bs/jszip-2.5.0/dt-1.10.20/af-2.3.4/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/rr-1.2.6/sc-2.0.1/sl-1.3.1/datatables.min.css", "css");
        AddResourcesListener.addDatatablesResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js", "css");
        AddResourcesListener.addDatatablesResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js", "css");
        AddResourcesListener.addDatatablesResourceIfNecessary("https://cdn.datatables.net/v/bs/jszip-2.5.0/dt-1.10.20/af-2.3.4/b-1.6.1/b-colvis-1.6.1/b-html5-1.6.1/b-print-1.6.1/cr-1.5.2/fc-3.3.0/fh-3.1.6/r-2.2.3/rg-1.1.1/rr-1.2.6/sc-2.0.1/sl-1.3.1/datatables.min.js", "js");
    }
The pdfmake javascript dependencies are listed as `css` not `js` like the others. Flipping it to JS still gives me an error, so I'm looking into this using the same technique.
jscrump59 commented 3 years ago

Genius! That's perfect!Thank you.

(Edited by @stephanrauh: You've accidentally included the original e-mail sent by GitHub, containing e-mail addresses and all. I hope I'm allowed to remove this).

exabrial commented 3 years ago

So I did find one additional bug:

    private static boolean shouldLibraryBeLoaded(final String initParameter, final boolean defaultValue) {
        final String suppressLibrary = BsfUtils.getInitParam(initParameter);
        if (suppressLibrary == null) {
            return defaultValue;
        }
        return !isTrueOrYes(ELTools.evalAsString(suppressLibrary));
    }

this: !isTrueOrYes(ELTools.evalAsString(suppressLibrary)); should probably be isTrueOrYes(ELTools.evalAsString(suppressLibrary));

Note that if you set net.bootsfaces.get_datatable_from_cdn = false in the web.xml, it looks like you do have to provide your own copy. Datatables.net is MIT Licensed, so it possibly could be distributed with Bootsfaces.

stephanrauh commented 3 years ago

Phew! All that sounds like a nasty bug. By the look of it, it's a combination of a bug - you're right, @exabrial, the two JavaScript resources should not be loaded as CSS files - and the increasing security awareness of the browsers.

I suggest dropping CDN support entirely. I'm not sure why CORS is a problem all of a sudden, but it's not unexpected. I suppose no CDN can legally add the CORS headers, so let's simply solve the problem by bundling the files with the library. That makes a lot of things easier, anyways.

In the meantime you can bundle the files with your application, as @exabrial describes. There's even some documentation here: https://showcase.bootsfaces.net/layout/resourcemanagement.jsf (but I agree it's not a masterpiece of documentation, I was always unhappy with it).

stephanrauh commented 3 years ago

@exabrial More likely than not, this method is not buggy. It's just very confusing. Maybe this can be solved by renaming it. On the other hand, if you follow my suggestion and remove CDN support in favor of bundling Datatables.net with the library, you're going to remove the method, anyways.

stephanrauh commented 3 years ago

@exabrial When you prepare the pull request, can you prepare an individual pull request per ticket, please? I know this is cumbersome - it requires maintaining different branches. But it's a lot easier to understand what's going on if there's only the minimum set of modifications.

exabrial commented 3 years ago

Yeah, so I can't get this to work with the CDN properly. I feel like that really isn't the job of the framework anyway. For instance cloudflare will automatically put your css/js on CDN with no work from the dev, so having that be part of the UI Lib is a bit of a stretch.

The PR I submitted serves the data-table support files up locally and removes the CDN option. This seems to work just fine. Can people on this thread test and give some feedback?

stephanrauh commented 3 years ago

I've merged your PR and uploaded it to Maven Central as snapshot 1.6.0. See issue #369 on how to get it.

Thanks a lot! Stephan