views:

129

answers:

1

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.

A: 

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.

BalusC
@BalusC So put simply, doing json seems quite esoteric when using JSF (MyFaces). And btw, explicitly making a question look so simple was intended to let in multiple solutions and not just one or two restricted (scenario-based) solutions.
nabeelalimemon