mojarra
mojarra copied to clipboard
Non queued AJAX requests and ES6 modules
Hi,
it would be great if JSF/mojarra would provide following features for modern web development:
-
Non-queued AJAX requests I know the reasons why the requests get queued, but the Spec and mojarra should provide the possibility for parallelization of multiple AJAX requests like primefaces does with async=true. Of course developers would have to use this feature with care in a stateless/RequestScoped environment.
-
Support of ES6 modules If an AJAX response containes inline JS code of type "module"
<script type="module">it won't get executed. mojarra uses eval for inline JS execution and eval does not support modules/imports. It works with primefaces ajax because they directly manipulate the DOM with replaceChild (via jquery)
We have a dependency on primefaces only because of these shortcomings, which is not nice. Apart from that I think JSF is a nice mature framework.
Thx, kind regards Oliver
@varoliver We would love to see something like this. Is this something you can work on? Note it won't make it for 4.0, but with your efforts maybe for 5.0?
Hi @mnriem thx for your reply. Unfortunately not at the moment. But as I read there are already some interesting things going on. @BalusC offered to do a rewrite of faces.js in https://github.com/eclipse-ee4j/mojarra/issues/5044#issuecomment-1046246568 Maybe he could implement Point 2 "Support of ES6 modules" within the scope of that rewrite?
Kind regards Oliver
What do you mean for "async" request?
actually inside faces.js what I see is:
req.async = true; // Default - Asynchronous
req.xmlReq.open(req.method, req.url, req.async);
so basically the request is async
from the Mozilla doc:
If you use an asynchronous XMLHttpRequest, you receive a callback when the data has been received. This lets the browser continue to work as normal while your request is being handled.
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests#asynchronous_request
Yes, the requests are async but multiple requests get queued by JSF. The browser could and should execute them in parallel.
I'll try to implement this on my forked mojarra!
... I made a PR of my faces.js version but it's still in the air ... :|
https://github.com/eclipse-ee4j/mojarra/pull/5141
Nice @pizzi80 that would be great.
@pizzi80 What is the status of this issue? Is the PR complete?
1. Non-queued AJAX requests
We probably need to add a boolean async attribute with the default value false to <f:ajax />
and assign it inside the AjaxHandler / AjaxBehavior processing
If I'm not mistaken I think this requires a ticket on the Faces API
After that, in "faces.js" the "sendRequest" method will skip the queue and immediately send the "XMLHttpRequest" if "async" is true
I'm going to open the ticket to Faces API
2. Support of ES6 modules
Interesting... I'm currently developing a new, unified DOM replacement algorithm. However, I've temporarily halted this work because the AJAX tests for Faces TCK are no longer functioning!
Before replacing 300 lines of code I think it's a good idea to have the ajax tests working :)
@pizzi80 Looks like a spec change here. Should it be tracked there?
Indeed belongs in jakartaee/faces project.
- Non-queued AJAX requests
Please continue in https://github.com/jakartaee/faces/issues/1844.
- Support of ES6 modules
Please continue in https://github.com/jakartaee/faces/issues/1598.