How to send manual jQuery Ajax request to JSF application?

前端 未结 1 1091
醉酒成梦
醉酒成梦 2021-01-25 05:29

I am doing a POST-request using jQuery which seems to succeed. But how can I work with that on server side and modify the response?
Do I need another servlet be

1条回答
  •  生来不讨喜
    2021-01-25 06:09

    If sending the ajax POST by usual JSF means (UICommand component, jsf.ajax.request(), etc, in flavor of , , , etc) is really not an option for some reason left unspecified in your question, then you'd indeed better create a separate servlet or even JAX-RS or JAX-WS webservice listening on those requests and returning e.g. XML, JSON, etc. JSF is a HTML form based MVC framework not a web service framework.

    You only need to take into account that you deal properly with JSF view state when you manipulate the HTML representation of JSF components afterwards. E.g. when you use custom JS/ajax to enable a disabled HTML button as generated by without involving/notifying JSF, then it won't appear as enabled in JSF component state and its action would never be invoked.

    See also:

    • How to use Servlets and Ajax?
    • How to generate JSON response from JSF?
    • How to invoke a JSF managed bean on a HTML DOM event using native JavaScript?
    • What is the need of JSF, when UI can be achieved from CSS, HTML, JavaScript, jQuery?

    0 讨论(0)
提交回复
热议问题