i would like to know if there is a way to fire a jsf managed bean method (with an AjaxBehaviorEvent type parameter: the same triggered when using f:ajax) directly by using a jquery ajax server request.By the way , i m a jsf developper and i didn't find an example about using jquery ajax with Java EE as a server-side framework, all examples i found were with php..so i wish to get a complete example about doing that. i think the other workaround maybe is to make a commandLink being submitted with jquery on the client side and passing parameters through that call but i prefer the former solution and i wish it work.
我想知道是否有一種方法可以通過使用jquery ajax服務器請求直接調用jsf托管bean方法(使用ajax行為事件類型參數:使用f:ajax時觸發)。順便說一下,我是一個jsf開發人員,我沒有找到使用jquery ajax和Java EE作為服務器端框架的例子,我找到的所有例子都是關於php的。我希望得到一個完整的例子。我認為另一個解決方案可能是在客戶端用jquery提交一個commandLink並通過調用傳遞參數,但我更喜歡前一種解決方案,我希望它能夠工作。
Thanks very much for help !
非常感謝你的幫助!
3 个解决方案
#1
7
Here you go:
給你:
doAwesomeness();
In your page:
在你的頁面:
Good luck!
好運!
#2
6
jQuery ajax request and JSF ajax request uses different js library's , I don't think there is a point in trying to mix those to too much...
jQuery ajax請求和JSF ajax請求使用不同的js庫,我認為沒有必要把它們混合得太復雜……
If you whish to fire a JSF managed bean action from jQuery you better use a hidden h:commandButton for that purpose...
如果要從jQuery啟動JSF托管bean操作,最好為此使用隱藏的h:commandButton…
JSF:
JSF:
if you want to pass some more hidden args you can add some more hidden JSF components ids in the hidden h:commandButton execute attribute, that way their corresponding properties will be updated on server side...
如果您想傳遞一些隱藏的args,您可以在隱藏的h:commandButton execute屬性中添加一些隱藏的JSF組件id,這樣它們相應的屬性將在服務器端更新……
js
js
$("#someId").click();
On the other side , if you want to use managed bean data in servlets that corresponds to your jQuery calls you can always access that JSF managed data, like this : JSF - get managed bean by name
另一方面,如果您想在與jQuery調用相對應的servlet中使用托管bean數據,您可以始終訪問JSF托管數據,如:JSF -按名稱獲取托管bean
#3
2
In the same vein as pointed out by islandguy, if you use Primefaces, you woud use the command, as follows :
按照islandguy所指出的相同的方式,如果你使用的是原始的面孔,你應該使用
命令,如下:
doAwesomeness();
with :
:
actionListener="#{awesomeBean.awesomeMethod}"
oncomplete="jsToExecuteOnAjaxSuccess()" />
Hope this helps..
希望這可以幫助. .