Skip to Content
0
Former Member
Mar 06, 2009 at 10:25 AM

Difference in node behaviour in action handler and supply function

24 Views

Hi,

I have got a view called TableView and I have defined a value node called TableData in its context.

I have a button called "Create" which has an event handler called Create.

In onActionCreate , I am trying to create a new element in the node TableData.

For this I have :

Approach 1:
// This doesn't work as createAndAddElement() is undefined on ITableDataNode
ITableDataElement element = ITableDataNode.createAndAddElement();
/*Fill up the element */

Approach 2:
//This works
ITableDataElement element = (ITableDataElement)wdContext.nodeTableData().createAndAddElement();
/*Fill up the element*/

However, when I define a supply function for TableData Node and try to fill it using Approach1 it works.

The code looks like

 for (int i=0; i<5 ; i++){
      /* node is IPrivateTableView.ITableDataNode passed to the supply function by the framework */
	 ITableDataElement element = (ITableDataElement) node.createAndAddElement();
	 element.setName("HarryPotter"+i);
	 element.setPrice(100*i);
	  }

Can you please guide me as to why Approach 1 doesn't work in onActionCreate()

Regards,

Arvind