on 10-13-2005 7:02 AM
Hi,
How can I create two dynamic Context nodes, one in ViewController and the other in Component Controller and finally create a context mapping between them.
Hi MK,
Giving you a sample code for the same :
<b>creating a node & attribute in the component controller</b>
// create a method in the component, write this code in it & call the method from the view
IWDNodeInfo NodeInfo = wdContext.getNodeInfo().addChild("comp_dyn_Node",null,true,true,false,false,false,true,null,null,null);
wdComponentAPI.getMessageManager().reportSuccess("Created a node ::"+NodeInfo.getName());
IWDAttributeInfo info = NodeInfo.addAttribute("comp_dyn_Attr" , "ddic:com.sap.dictionary.string");
wdComponentAPI.getMessageManager().reportSuccess("Created an attribute ::"+info.getName());
<b>Creating & mapping a node & attribute in the view</b>
IWDNodeInfo NodeInfo = wdContext.getNodeInfo().addMappedChild("view_dyn_Node",null,true,true,false,null,false,true);
IWDNodeInfo comp_node_info = wdThis.wdGetDynamic_mappingController().wdGetContext().getNodeInfo().getChild("comp_dyn_Node");
wdComponentAPI.getMessageManager().reportSuccess("Created a node ::"+NodeInfo.getName());
wdComponentAPI.getMessageManager().reportSuccess("getting the component node ::"+comp_node_info.getName());
NodeInfo.setMapping(comp_node_info,true);
IWDAttributeInfo info = NodeInfo.addMappedAttribute("view_dyn_Attr",".Dynamic_mapping.comp_dyn_Node.comp_dyn_Attr");
wdComponentAPI.getMessageManager().reportSuccess("Created an attribute ::"+info.getName());
wdContext.getChildNode("view_dyn_Node",wdContext.getLeadSelection()).getCurrentElement().setAttributeValue("view_dyn_Attr","Test Value for dynamically created node mapping");
wdComponentAPI.getMessageManager().reportSuccess("Reading from the new attribute ::"+wdContext.getChildNode("view_dyn_Node",wdContext.getLeadSelection()).getCurrentElement().getAttributeValue("view_dyn_Attr"));
wdComponentAPI.getMessageManager().reportSuccess("Reading from the component attribute ::"+wdThis.wdGetDynamic_mappingController().wdGetContext().getChildNode("comp_dyn_Node",wdContext.getLeadSelection()).getCurrentElement().getAttributeValue("comp_dyn_Attr"));
Hope this helps,
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi MK,
We can set the cardinality of the created node through the fourth & fifth parameter of the addChild() method.
4th parameter :
mandatory - indicates, whether the described Node is guaranteed to have at least one element
5th parameter :
multiple - indicates, whether the described Node may contain more than one element
Hope this helps,
Best Regards,
Nibu.
See Javadoc for IWDNodeInfo
Armin
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.