Retrieve data present in dynamic table using CAF javascript

hi All,

I am facing an issue in retrieving values from a dynamic table at client side using CAF javascript.

Let me explain my problem with an example:

  1. In my portlet, I have a table which is binded to a SelectableListTableContentProvider.
  2. In the table, I have a button (which will be rendered per each row in the dynamic table at run time).
  3. wrote following code in the ‘on click’ event:
var table = CAF.model("#{activePageBean.clientIds['myTableId']}");
	var row = table.get(0);
	var sampleTextId= row.getControlId("sampleText");
	var sampleTextObj = CAF.model(sampleTextId);
	alert(sampleTextObj.getValue());
  1. I am expecting it to give the ‘sampleText’ value present in the 0th row.

But it is giving javascript error 'Object doesn’t support this property or method’ at line 2 in the above code.
I am suspecting that it is not treating variable ‘table’ as a CAF.Table.Model object.

If I put a button outside of this dynmaic table and put the same javascript in the ‘onclick’ event, then i am able to get the ‘sampleText’ value.

But, as per my requirement, I have to execute this javascript onclick of the button which is rendered on each row present in the table.

Could you please advise why the javascript for the button present inside table is not working?

Please find the attached package which illustrates in detail.

(we are using webMethods 7.1.2 product suite).

Kind regards,
Raja sekhar Kintali
SAGUpload2.zip (16 KB)

Would you consider the approach listed on this thread? http://tech.forums.softwareag.com/viewtopic.php?t=24139&highlight=javascript+table&sid=d6ca276e4cbb59442c937b4587c75342

Regards,
–mark

The problem there is that while the table control is being rendered, the “#{activePageBean.clientIds[‘myTableId’]}” expression resolves to clientId of the current row being rendered. It doesn’t resolve to the clientId of the table itself.

That is expected.

Since your snippet appears to be interested in getting the row model eventually anyway, you could probably just simplify your script like this:

   var row = CAF.model("#{activePageBean.clientIds['myTableId']}"); 
   var sampleTextId= row.getControlId("sampleText"); 
   var sampleTextObj = CAF.model(sampleTextId); 
   alert(sampleTextObj.getValue());

hi Mark,

Thanks for your reply.
I will try adding the event listener and will let you know the outcome.

Kind regards,
Raja sekhar Kintali

hi Eric and Mark,

Thank you for your inputs and detailed explanation.

binding a listener and getting the row model as mentioned above- both the ways are working in my case.

Kind regards,
Raja sekhar Kintali