呼叫JSF动作直通jQuery的阿贾克斯动作、JSF、阿贾克斯、jQuery

2023-09-10 17:45:41 作者:天生的王者

如何调用JSF动作方法直通jQuery的AJAX?

How to call a JSF action method thru jQuery AJAX?

推荐答案

直接通过AJAX调用JSF的观点是不明智的,除非你的JSF堆栈支持AJAX,你知道如何构建请求以这样的方式堆栈理解。这里的错误可能会导致问题的视图状态和难以诊断的错误。

Calling a JSF view directly through AJAX is unwise unless your JSF stack supports AJAX and you know how to construct the request in such a way that the stack understands. Mistakes here can result in problems with the view state and difficult to diagnose errors.

核心JSF 1.2(之前)没​​有直接的AJAX支持; 提供不同程度的支持AJAX的第三方框架。 JSF 2 增加了AJAX的JavaScript库的核心框架(的大卫·吉尔里演示),因此使用,如果可能的。

Core JSF 1.2 (and before) does not have direct AJAX support; 3rd party frameworks provide varying degrees of AJAX support. JSF 2 adds AJAX JavaScript libraries to the core framework (David Geary demonstrates), so use that if possible.

一个倒过来,这一切都是用servlet来直接与模型交互(即不是回发到JSP / facelet中查看)。这可能是适当的,这取决于究竟你在做什么。

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