Calling Web service connector from client size script

In a CAF application, how can be call a webservice connector from client side javascript and get the resulting data? Basically we have a table with many records. Part of the data that is displayed in the table takes a considerable amount of time (5+ seconds). So we decided to display the table and load the data for each record in the background. We tried using async commands but the screen becomes unresponsive while we are loading the data.
We will be calling the service in the background and only execute the script when we receive the data from the server.

CAF doesn’t yet support an easy way to deliver JSON results from async commands. It is a definitely a very reasonable idea, and something we are pursuing in the next major release. (Part of the investigation is also what would be the easiest way for CAF developers to consume the JSON results with a minimum of custom javascript)

As a result, you have a couple of options. The first would be to consume web services directly from IS using the CAF.Request Class (javascript class which wraps the Ajax.Request class from prototype: Using prototype.js v1.5.0). However, this will introduce a problem of cross-domain requests that you’ll have to overcome.

The other option is to create a Servlet in your CAF Application that directly handles the requests and invokes the web service and returns the data in your preferred format. The challenge here is to ensure you have a valid FacesContext in your Servlet.

There might be other approaches, but these are the first two that come to mind.

Regards,
–mark

How do I create a Servlet inside a CAF Application?

Do I need to create a new webapp application project or it is possible to reuse the Portlet App where the task views are already?

You can deploy a servlet in a CAF Portlet Application in the same way that you can deploy a servlet in a standard WAR file.

You can either create it by hand, or you can attempt to use the new Serlvet Wizard that comes with the Designer Distribution.

Regards,
–mark