on 09-16-2008 11:39 AM
hi everyone,
i need to create a dropdownbyindex-element dynamiclly in the code, with values from an dynamiclly generated arraylist. but i can only bind a value-node to the ddbi-element.
so. how can i create a value-node with one value-attribute dynamiclly and set the value according to the arraylist?
thanks and best regards,
constantin
it doesnt work for me...
heres my code (6.40)
IWDDropDownByIndex ddbi = (IWDDropDownByIndex) view.createElement(IWDDropDownByIndex.class, "table_selection_ddbi");
IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("table_selection_node", null, true, true, true, false, false, true, null, null, null);
nodeInfo.addAttribute("value", "ddic:com.sap.dictionary.string");
wdContext.getChildNode("table_selection_node", 0).bind((List) list);
ddbi.bindTexts("table_selection_node");
please help
regards,
constantin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you really need to create the UI element and the context node programmatically? What is the use-case?
Why not just create the DropDownByIndex UI element and the context node, say "Items" at design-time and provide a supply-function "supplyItems()" for the context node that uses your list as input. Whenever the list changes, just call wdContext.nodeItems().invalidate() which triggers a call of the supply function.
Armin
Hi,
To resolve your error,
Your array list need to be slightly changed as follows
IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("Node", null, true, CMICardinality.ONE,
CMICardinality.ONE, true, null);
nodeInfo.addAttribute("Test", "ddic:com.sap.dictionary.string");
ArrayList<IWDNodeElement> arr = new ArrayList<IWDNodeElement>();
for(int x=0; x<5;x++)
{
IWDNodeElement element = wdContext.getChildNode("Node", 1).createAndAddElement();
element.setAttributeValue("Test", "a");
arr.add(element);
}
wdContext.getChildNode("Node", 0).bind(arr);
Regards
Ayyapparaj
Example: Create a context node "Items" with a string attribute "text", create a DropDownByIndex "ItemSelector", bind it to the node. Fill the node from some array of strings.
void wdDoInit()
{
/* Create the meta-data */
IWDNodeInfo itemsNodeInfo = wdContext.getNodeInfo().addChild
(
"Items",
null, /* value node */
true, /* singleton */
false, true, /* cardinality = 0:n */
false, false, /* selection = 0:1 */
true, /* initialize lead-selection */
null, /* data type */
null, null /* no supplier and disposer */
);
itemsNodeInfo.addAttribute("text", "ddic:com.sap.dictionary.string");
/* Fill the node from sample data */
String[] values = { "First", "Second", "Third" };
IWDNode itemsNode = wdContext.getChildNode("Items", 0);
for (int i = 0; i < values.length; ++i)
{
IWDNodeElement e = itemsNode.createElement();
e.setAttributeValue("text", values<i>);
itemsNode.addElement(e);
}
}
wdDoModifyView(...)
{
if (firstTime)
{
IWDUIElementContainer top = (IWDUIElementContainer) view.getRootElement();
IWDDropDownByIndex itemSelector = (IWDDropDownByIndex) view.createElement(IWDDropDownByIndex.class, "ItemSelector");
itemSelector.bindTexts("Items.text");
top.addChild(itemSelector);
}
}
Übungsaufgabe: Create an action and assign it to the "onSelect" event of the drop-down list. (Hint: You have to use a predefined event handler method.)
Armin
try...
wdContext.node<nodename>().bind((List)<arrayListObject>);
i.e. typecast your ArrayList object to a List object.
i used it and it worked fine.
regards,
-Amol Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
how can i create a value-node with one value-attribute dynamiclly and set the value according to the arraylist?
Following is the code to create a value node and attribute
IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("Node", null, true, CMICardinality.ONE,
CMICardinality.ONE, true, null);
nodeInfo.addAttribute("Test", "ddic:com.sap.dictionary.string");
ArrayList arr = new ArrayList();
arr.add("a");
arr.add("b");
arr.add("c");
wdContext.getChildNode("Node", 0).bind(arr);
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Ayyapparaj KV,
thats how i assumed it and tried your example but i cant bind an arraylist to the node. i get the following error which is self-explaining... i need to transform the arraylist to a node element.. but how?
com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(WDGeoView.table_selection_ddbi_node): you must bind NodeElements to a value node
remember.. i cant set the node and the attributes in the context by hand.. they need to be set by runtime
regards,
constantin
Hi,
refer this link,
http://help.sap.com/saphelp_nw70/helpdata/EN/3b/f1754276e4c153e10000000a1550b0/content.htm
Regards,
ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
add a drop down by index UI element to the view.
make a node in the context with 0-n cardinality.
i.e. the node can hold 0 to n elements in it.
make the attributes in the node.
make instances of the node as follows.
read your vector object in a loop...
and add elements for each element in the drop down.
For(initialisation; //readVectorOneByOne() ; increment)
{
IPublic<viewname>.I<NodeName>Element objEle = wdContext.node<NodeName>().create<NodeName>Element();
objEle.set<ContextElement>();
objEle.set.....();
wdContext.node<NodeName>().addElement(objEle);
}
regards,
-Amol Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.