-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataTable onSelect works but generates javascript "network error" #1164
Comments
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 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> |
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.
|
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? |
I'm using tomee-8.0.4-webprofile.
This is my web.xml:
```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 GitHub<#1164 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AC2DNJMJJRDMVDBQ2D4ATUDS6D4NFANCNFSM4W7V3O6Q>.
|
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..
|
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 |
I have given up - Datatables in Bootsfaces are currently incompatible with MyFaces. I had to return to TomEE PLUME to keep my application running. |
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. |
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.
|
Would a possible patch would be to load these Javascript files as resources rather than from a CDN? |
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
Pulling up that source file it calls |
That being said, I think there's still a bug: 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");
}
|
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).
|
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: Note that if you set |
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). |
@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. |
…nerates javascript 'network error'. Remove CDN option for datatable script files
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? |
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! |
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
Can you see what I might be doing wrong?
Thanks
The text was updated successfully, but these errors were encountered: