Using the IS service output in javascript

Hi,
I am having one application where I need to populate the tables in UI based on user selection(table names will be listed in one drop-down and user can select any table.).
Since the columns will be different in different tables, I am using javascript to dynamically populate column names. It is working fine. But I am not able to populate the row contents(output from the IS service is document list). I have created one content provider for the output from IS service(the IS service gives the table values) . But, I dont know how to get the contents from the content provider in javascript(like we do for controls). So I need to know how to get the values from the content provider or from the output of the IS service inside javascript.

Also if there is any other approach for this, please help…

Thanks in advance…

I would try the following:

  1. Create a java function that iterates through the content provider, creating some JSON representing the data returned from the web service.
  2. Drop a Script Output Block onto the View that is bound the output of the function in #1.

Hope this helps.
–mark

Hi Mimel,

Thanks for the response…

Actually I need to populate column names as well as row contents dynamically at run-time into the view. So, I am using one IS service which gives two outputs.
*)One is string variable which contains the column names seperated by delimiter.
*)Other is the doucment list which is having table values.
I am binding the string variable(columnNames) variable into one hiddenInput control. This control I am using in javascript to get the column names at run-time.

But for populating the row values I need to get the values from the document list in javascript which is the output from the IS service. I dont know whether we can bind this document list to any of the control and from the control, we can get the value inside javascript. So please let me know if there is any possibility of getting the value directly from the service or can I bind the output(doc list) to a control and get the value. I am planning to generate rows and cells using javascript at run-time.

Also, as alternative to this approach, I have generated one web service descriptor for the IS service and I have generated WSDL to check whether there is any possibility of invoking the IS service directly from the javascript so that I can get the output doc list directly by invoking the IS service using the WSDL path. But this is also not working.

Please let me know whether I can work out the requirement using any of the above approaches.

Also, I am not able to figure out the logic that you have given. Can you please explain it? Even If I loop over the content provider, I need to know how I can bind the values to the table row control and I am not sure whether I can be able to populate the column names.

Thanks in advance…

Perhaps the general approach isn’t the best for your use case. What might work better is to use the traditional approach of binding the webservice results to a table. Then you can use conditional statements to either render or not render various columns based on the circumstances.

If that approach works for you, it will be much easier to code and maintain.

Regards,
–mark

This is not ideal solution to your overall use case, but this addresses one of your queries on “How do I access IS Service Doc List values via JavaScript”.

  1. If your IS Service Output is not already rendered on the UI as an Async Table bound to its Content Provider, please do so. If you do not want it visible, wrap it with a Hideable Panel.

  2. Place the following piece of JS in a JavaScript Block at the very bottom of your view.


function accessTableValuesInJS()
{
	var myTable = CAF.model("#{activePageBean.clientIds['asyncTable2']}"); 
	var myTableRows = myTable.list(); 

	for (var i = 0; i < myTableRows.length; i++) 
		{ 
			var col1 = myTableRows[i].getControlId("htmlOutputText2"); // where htmlOutputText2 is the TextControl bound to the value in the Async Table Cell
			var col2 = myTableRows[i].getControlId("htmlOutputText4");
			var col3 = myTableRows[i].getControlId("htmlOutputText6");

			alert("Row : " + i + " --> " + CAF.model(col1).getValue() + " , " + CAF.model(col2).getValue() + " , " + CAF.model(col3).getValue());			
		}
}

window.onload = accessTableValuesInJS;

var windowLoaded = window.onload;
if(windowLoaded)
{
	accessTableValuesInJS();
}

Hope this helps!!