marcorinck / jsf-updates-angular

Update angularJS after JSF Ajax requests are complete
5 stars 2 forks source link

Not compatible to PrimeFaces #1

Open stephanrauh opened 9 years ago

stephanrauh commented 9 years ago

In a pure PrimeFaces view there's no JSF object. So the injector fails with this message:

Uncaught ReferenceError: jsf is not defined
jua-0.1.0.js.jsf?ln=AngularFaces:129 (anonymous function)

image

stephanrauh commented 9 years ago

This issue is addressed by my pull request.

marcorinck commented 9 years ago

I didn't knew that this was a thing ... pure primefaces views :-)

JUA doesn't know ANYTHING currently about primefaces. And I'm hesitating to hardcode something into it for a specific JSF framework library. I would prefer it greatly, that the utilities are there to attach any jsf framework.

I only know an older PF version (3.0.1) and this version uses jquery internally for ajax requests.

If this is still the case and jquery is present in the current page, jua could do something like this:

$("body").bind("ajaxComplete", function() {
   destroyScopes();
}

$("body").bind("ajaxSuccess", function() {
  handleAjaxUpdates();
}

(code is not tested, I think jquery syntax changed between versions a bit)

Does this still work for newer PF versions?

marcorinck commented 9 years ago

Ah, and I did not understand what you had done in your PR for Primefaces 5+? Can you please elaborate? Thanks!

tandraschko commented 9 years ago

Hey,

in PF you can catch the ajax events via: $(document).on('pfAjaxComplete', function() { ... }); $(document).on('pfAjaxSuccess', function() { ... }); $(document).on('pfAjaxStart', function() { ... }); $(document).on('pfAjaxSend', function() { ... }); $(document).on('pfAjaxError', function() { ... });

I did the same for DeltaSpike as you can see here: https://github.com/apache/deltaspike/blob/master/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js#L248

I may add bridge in PF to support jsf.ajax.addOnEvent() event handling in the future. (It would be great if you could add a feature request to the primefaces issue tracker! :))

marcorinck commented 9 years ago

So normal jquery ajaxComplete/ajaxSuccess event handlers are not called when PF5+ is doing ajax requests anymore? Do you not use jquery ajax anymore? If not, when did it change? Its working in old PF 3 at least.

tandraschko commented 9 years ago

i'm sure the normal jquery ajax event handlers are called but i'm not sure if you would like to catch every jquery ajax event. Users may also use "native" jquery ajax to do something.

marcorinck commented 9 years ago

Yes, I want to handle every ajax request as I don't want to have any framework-specific code in jua.

I have to analyze the response text anyway to check if its an JSF xml response and to inform angular about it.

Thanks for the info!