on 10-12-2009 10:02 AM
Hi,
I'm preparing table application.
a table's columns number is dynamic, so i must add field to context node to bind it to table.
Is it possible?If possible, how?
Thanks
Dear,
You can use the following code to create a value node & then add value attributes
to this node using the following code :
// Get the metadata object for the context root node
IWDNodeInfo rootNodeInfo = wdContext.getNodeInfo();
// Create a metadata object to describe a new independent node
// called "YourNode"
IWDNodeInfo yourNodeInfo =
rootNodeInfo
.addChild("YourNode", // Name
null, // Structure reference
true, // Is singleton?
false, true, // Cardinality
false, false, // Selection cardinality
true, // Initialise lead selection?
null, // Datatype
null, // Supplier function
null); // Disposer function
// Add the attribute metadata to the new node info object
yourNodeInfo.addAttribute("Attribute1","ddic:com.sap.dictionary.integer");
yourNodeInfo.addAttribute("Attribute2","ddic:com.sap.dictionary.string");
yourNodeInfo.addAttribute("Attribute3","ddic:com.sap.dictionary.date");
yourNodeInfo.addAttribute("Attribute4","ddic:com.sap.dictionary.string");
In the above a code node "YourNode" is created dynamically and then the attributes
"Attribute1","Attribute2","Attribute3", "Attribute4" are added .
Warm Regards
Upendra Agrawal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
an example:
create Context node
public void wdDoInit()
{
//@@begin wdDoInit()
//Node
IWDNodeInfo nodeInfo = wdContext.getNodeInfo();
IWDNodeInfo mynode =nodeInfo.addChild("nodeName", null, true, false, true, false, false, true, null, null, null);
mynode.addAttribute("attributeName", "ddic:com.sap.dictionary.string");
IWDNode node = wdContext.getChildNode("nodeName", 0);
//element
IWDNodeElement element = node.createElement();
element.setAttributeValue("attributeName", "Value1");
node.addElement(element);
//@@end
}
binding:
public static void wdDoModifyView(IPrivateContextdinView wdThis, IPrivateContextdinView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime){
IWDTransparentContainer rootElement = (IWDTransparentContainer) view.getRootElement();
IWDTable myTable = (IWDTable) view.createElement(IWDTable.class,"MyTable");
myTable.bindDataSource(wdContext.getChildNode("nodeName", 0).getNodeInfo());
IWDTableColumn col1 = (IWDTableColumn)view.createElement(IWDTableColumn.class,"col1");
IWDTextView txtw1 =(IWDTextView)view.createElement(IWDTextView.class,"txtw1");
txtw1.bindText("nodeName.attributeName");
IWDTableCellEditor cled1 = txtw1;
col1.setTableCellEditor(cled1);
myTable.addColumn(col1);
myTable.setVisibleRowCount(5);
rootElement.addChild(myTable);
}
//@@end
}
enjoy yourself : )
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.