Using jquery ajax to call a jsf managed bean method (an AjaxBehaviorEvent listener handler)

前端 未结 3 768
悲&欢浪女
悲&欢浪女 2021-02-09 15:17

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 jqu

3条回答
  •  生来不讨喜
    2021-02-09 16:15

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

    If you whish to fire a JSF managed bean action from jQuery you better use a hidden h:commandButton for that purpose...

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

    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

提交回复
热议问题