cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Table binding at runtime

Former Member
0 Kudos

I am trying to do something similar to what was being asked about here: create a table at runtime without knowing how many or what columns there are in that table. I guess I don't understand the step where you 2. Create each attribute associated to a column (is this done programatically?). I can't figure out how to create and then add a value attribute to the context so that I can build the columns for the table. Is there anyone that can explain this better? Or point me to where I can see an example somewhere?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

you can programatically get the nodeinfo of the node to which you need to create the attribute and there just give addAttribute()

Then you can use it as your usual context attribute and set and get value.

wdcontext.node<nodename>().getattribute();

Former Member
0 Kudos

hello

this code might help u.

to creat a node and attribute:


IWDNodeInfo node = wdContext.getNodeInfo().addChild("rootNode",null,true,false,true,true,true,true,null,null,null);
/** adding elements to rootNode */
node.addAttribute("name","com.sap.dictionary.string");

(this code can be written in doInit() or onAction().

to create colomns and celleditors:



// create table.
IWDTable table = (IWDTable)view.createElement(IWDTable.class,"mainTable");
table.bindDataSource("rootNode");
// create colomns
IWDTableColumn col = (IWDTableColumn) view.createElement(IWDTableColumn.class,"col1");
// set header
IWDCaption cap = (IWDCaption) view.createElement(IWDCaption.class,"cap1");
col.setHeader(cap);
cap.setText("Name"); 
// add colomn to the table
table.addColumn(col1);
// create cell editor and bind it to the node attribute.
IWDTextView textView1 =(IWDTextView) view.createElement(IWDTextView.class,"text1");
textView1.bindText("rootNode.name");
col.setTableCellEditor((IWDTableCellEditor)textView1);


this code u write in doModify();

to create elements:


IWDNode nodeIterate = wdContext.currentContextElement().node().getChildNode("rootNode",0);
IWDNodeElement element = nodeIterate.createElement();
nodeIterate.addElement(element);
element.setAttributeValue("name","Piyush");

regards,

Piyush.

Answers (1)

Answers (1)

Former Member
0 Kudos

You do not necessarily need to create or add context attributes at runtime. If you need to do that, use the context API (IWDNodeInfo, IWDAttributeInfo etc.)

Examples on how to build context structures at runtime may be found in the book "Inside Web Dynpro for Java" by Chris Whealy.

Perhaps you can give more details on your use case.

Armin