cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Context Creation

Former Member
0 Kudos

Hi,

I am trying to create & fill a Context dynamically.

But I can' able to add more than one element to the root node.

Please find the code below.

/*Creation of ValueNode and attribute */

IWDNodeInfo childNode = wdContext.wdGetAPI().getRootNodeInfo().addChild("Child", null, true, true, true, true, false, false, null, null, null);

IWDNode n= wdContext.getChildNode("Child",wdContext.LEAD_SELECTION);

IWDAttributeInfo at1=childNode.addAttribute("Attrib1","com.sap.dictionary.string");

/* Populating the above created context */

IWDNodeElement testNodeEle = wdContext.getChildNode("Child", IWDNode.LEAD_SELECTION).createElement();

testNodeEle.setAttributeValue("Attrib1","Value1");

wdContext.getChildNode("Child",IWDNode.LEAD_SELECTION).addElement(testNodeEle);

IWDNodeElement testNodeEle1 = wdContext.getChildNode("Child", IWDNode.LEAD_SELECTION).createElement();

testNodeEle1.setAttributeValue("Attrib1","Value2");

wdContext.getChildNode("Child",IWDNode.LEAD_SELECTION).addElement(testNodeEle1);

In the above code I am trying to add two elements to the root node.But it always adding one element only.

I feel the problem with creating root node.Please let me know the solution.

Thanks & Regards

Anilkumar

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Please find the code below where i am creating and binding the Table dynamically.

detailgroup.destroyAllChildren();

int id=0;

IWDTable table=(IWDTable)myView.createElement(IWDTable.class,"table");

ResultSetMetaData metaData=rs.getMetaData();

int columnCount=metaData.getColumnCount();

IWDNodeInfo nodeinfo=wdContext.getNodeInfo();

wdContext.invalidate();

IWDNodeInfo childNode = wdContext.wdGetAPI().getRootNodeInfo().addChild("Child", null, true, true, true, true, false, false, null, null, null);

IWDNode n= wdContext.getChildNode("Child",wdContext.LEAD_SELECTION);

for(int count=1;count<=columnCount;count++)

{

IWDAttributeInfo at1=childNode.addAttribute(metaData.getColumnName(count),"com.sap.dictionary.string");

IWDTableColumn column=(IWDTableColumn)myView.createElement(IWDTableColumn.class,metaData.getColumnName(count));

IWDCaption colHeader=(IWDCaption)myView.createElement(IWDCaption.class,metaData.getColumnName(count) + id);

colHeader.setText(metaData.getColumnName(count));

column.setHeader(colHeader);

IWDTextView txtview=(IWDTextView)myView.createElement(IWDTextView.class,"txtView"+id);

txtview.bindText(at1);

IWDTableCellEditor editor=(IWDTableCellEditor)txtview;

column.setTableCellEditor(editor);

table.addColumn(column);

id++;

}

detailgroup.addChild(table);

Regards

Anilkumar

uwe_reeder
Explorer
0 Kudos

Hello Anilkumar,

I see no code that binds the table to the node. I would have expected something like table.bindDataSource(childNode).

Regards, Uwe

Former Member
0 Kudos

Hi Uwe ,

Thanx a lot .Its working now

Regards

Anilkumar

Former Member
0 Kudos

Hi,

I am binding the node to a table.But i am getting only one row in the table.

Please let me know how to do this in a simpler way.

Thanks & Regards

Anilkumar

uwe_reeder
Explorer
0 Kudos

Two simplifications: wdContext.wdGetAPI().getRootNodeInfo() is wdContext again. Also, once you have found your node and stored it in n, you do not need to call wdContext.getChildNode("Child"...) again and again.

About your problem: Binding a table to the node has to be done dynamically, too. What does your code in wdDoModifyView look like?

Regards, Uwe

uwe_reeder
Explorer
0 Kudos

Hello Anilkumar,

your code is correct (although unnecessarily complicated).

I've taken it into a project of mine and observed that "Child" contained two elements afterwards. How do you come to the assumption that it only contains one element?

Regards, Uwe