user18943
user18943

Reputation: 747

How to send/receive json object between JQuery and JSF (Myfaces Tomahawk component library)

I am using JSF(Myfaces Tomahawk component library) and jQuery. All I want is to send json object to jsf bean when i click a button and similarly send a json object(from jsf bean) to page when it's loading.

Upvotes: 1

Views: 2733

Answers (1)

BalusC
BalusC

Reputation: 1108902

Implement a custom ViewHandler and/or PhaseListener which does the job. All you basically need to do is to hook on specific requests (ajaxical requests usually have a X-Requested-With: XMLHttpRequest header) and have a reference to the associated JSF component tree in the session so that you can do the works on it.

This is however quite a work which requires a solid understanding of how JSF works under the hoods. Since you're already asking a trivial question like this, I think it's going to be a very long journey. I would then strongly recommend to just grab an existing component lirbary which enables using ajaxcal magics in JSF, like PrimeFaces, RichFaces, OpenFaces, IceFaces, Trinidad, etc. You'll be ready in a few hours instead of months.

Upvotes: 3

Related Questions