mojarra icon indicating copy to clipboard operation
mojarra copied to clipboard

Non queued AJAX requests and ES6 modules

Open varoliver opened this issue 4 years ago • 9 comments
trafficstars

Hi,

it would be great if JSF/mojarra would provide following features for modern web development:

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

  2. 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 avatar Aug 04 '21 15:08 varoliver

@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?

mnriem avatar Feb 06 '22 21:02 mnriem

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

varoliver avatar Apr 01 '22 17:04 varoliver

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

pizzi80 avatar Jun 24 '22 11:06 pizzi80

Yes, the requests are async but multiple requests get queued by JSF. The browser could and should execute them in parallel.

varoliver avatar Jul 22 '22 18:07 varoliver

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

pizzi80 avatar Sep 28 '22 13:09 pizzi80

Nice @pizzi80 that would be great.

melloware avatar Sep 28 '22 16:09 melloware

@pizzi80 What is the status of this issue? Is the PR complete?

mnriem avatar Sep 18 '23 21:09 mnriem

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 avatar Sep 19 '23 09:09 pizzi80

@pizzi80 Looks like a spec change here. Should it be tracked there?

mnriem avatar Sep 19 '23 21:09 mnriem

Indeed belongs in jakartaee/faces project.

  1. Non-queued AJAX requests

Please continue in https://github.com/jakartaee/faces/issues/1844.

  1. Support of ES6 modules

Please continue in https://github.com/jakartaee/faces/issues/1598.

BalusC avatar Sep 16 '24 17:09 BalusC