Skip to Content
avatar image
Former Member

Creating nodes straight under context dynamically

Hi,

I need to build a dynamic amount of tables dynamically. They all have the same buildup (same columns) but their data is different. I wanted to solve this by creating nodes under the context dynamically and manually binding them to created tables....the only problem is I can't find a way to create a node dynamically.....

Found some links to a weblog but its seems out of sync...

can anyone help me out here?

Much thanks & regards,

Hugo

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jul 11, 2007 at 09:43 AM

    Hi

    Code for creating a node dynamically and code for creating the table dynamically and binded it dymaically created value node

    public void wdDoInit()

    {

    //@@begin wdDoInit()

    // creation of value Node for table dynamically

    IWDNodeInfo nodeinfo=wdContext.getNodeInfo().addChild("tablenode",null,true,true,true,false,true,true,null,null,null);

    nodeinfo.addAttribute("tableattr1","ddic:com.sap.dictionary.string");

    nodeinfo.addAttribute("tableattr2","ddic:com.sap.dictionary.string");

    nodeinfo.addAttribute("tableattr3","ddic:com.sap.dictionary.string");

    //Code for removing the intial element in the table node

    IWDNode node=wdContext.getChildNode("tablenode",0);

    IWDNodeElement ne=node.getElementAt(0);

    node.removeElement(ne);

    // filling the data for table node

    Object obj1=..; // Data for table convert to object type

    Object obj2=..;

    Object obj3=..;

    //creating elements for tablenode and displaying it

    IWDNode node=wdContext.getChildNode("tablenode",0);

    IWDNodeElement ne1=node.createElement();

    ne1.setAttributeValue("tableattr1",obj1);

    ne1.setAttributeValue("tableattr2",obj2);

    ne1.setAttributeValue("tableattr3",obj3);

    node.addElement(ne1);

    //@@end

    }

    public static void wdDoModifyView(IPrivateDynamicProgrammingView wdThis, IPrivateDynamicProgrammingView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

    {

    //@@begin wdDoModifyView

    if(firstTime){

    IWDTransparentContainer con=(IWDTransparentContainer)view.getElement("RootUIElementContainer");

    //creation of table

    IWDTable table =(IWDTable)view.createElement(IWDTable.class,"table1");

    table.bindDataSource("tablenode");

    IWDTableColumn tablecolumn1=(IWDTableColumn)view.createElement(IWDTableColumn.class,"tablecolumn1");

    IWDTextView tabletextview1=(IWDTextView)view.createElement(IWDTextView.class,"ttv1");

    tabletextview1.bindText("tablenode.tableattr1");

    IWDTableCellEditor editor1=tabletextview1;

    tablecolumn1.setTableCellEditor(editor1);

    IWDCaption cap1=(IWDCaption)view.createElement(IWDCaption.class,"cap1");

    cap1.setText("Name");

    tablecolumn1.setHeader(cap1);

    table.addColumn(tablecolumn1);

    IWDTableColumn tablecolumn2=(IWDTableColumn)view.createElement(IWDTableColumn.class,"tablecolumn2");

    IWDTextView tabletextview2=(IWDTextView)view.createElement(IWDTextView.class,"ttv2");

    tabletextview2.bindText("tablenode.tableattr2");

    IWDTableCellEditor editor2=tabletextview2;

    tablecolumn2.setTableCellEditor(editor2);

    table.addColumn(tablecolumn2);

    IWDTableColumn tablecolumn3=(IWDTableColumn)view.createElement(IWDTableColumn.class,"tablecolumn3");

    IWDTextView tabletextview3=(IWDTextView)view.createElement(IWDTextView.class,"ttv3");

    tabletextview3.bindText("tablenode.tableattr3");

    IWDTableCellEditor editor3=tabletextview3;

    tablecolumn3.setTableCellEditor(editor3);

    table.addColumn(tablecolumn3);

    con.addChild(table);

    }

    //@@end

    }

    Thanks and Regards,

    Arun Srinivasan

    Add comment
    10|10000 characters needed characters exceeded