Skip to Content
avatar image
Former Member

Dynamic Context Creation

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Sep 28, 2004 at 09:40 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 28, 2004 at 02:58 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Sep 28, 2004 at 05:32 PM

    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

    Add comment
    10|10000 characters needed characters exceeded