JSF action invocation via jQuery ajax

How to call JSF action method via jQuery AJAX?

+3
source share
2 answers

Calling a JSF view directly through AJAX is unreasonable if your JSF stack does not support AJAX, and you know how to build the request so that the stack understands. Errors here can lead to problems with the status of the view and make it difficult to diagnose errors.

Core JSF 1.2 (and before) does not have direct AJAX support; Third-party frameworks provide varying degrees of AJAX support. JSF 2 adds AJAX JavaScript libraries to the main structure ( David Geary demonstrates ), so use this if possible.

One way around this is to use a servlet to interact directly with the model (i.e. not send back to the JSP / Facelet view). This may be appropriate, depending on what you are doing.

+1
source

Have you tried to use the attribute data a4j:jsFunctionto return a value? This will simulate a synchronization call.

eg.

<a4j:jsFunction action="#{myBean.someAction}" data="#{myBean.someResult}" name="whatever" reRender="something"/>
0
source

Source: https://habr.com/ru/post/1718538/


All Articles