cancel
Showing results for 
Search instead for 
Did you mean: 

Context Mapping a dynamically created node?

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi Nibu,

that looks very helpful.

Can one also set the cardinality of the dynamic node?

Former Member
0 Kudos

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.

anbusivam_s
Participant
0 Kudos

Hi Wilson,

I need to know what is the use of all these parameters of this addChild method. Where can I find the help which explains what is the use of each parameter?

Former Member

Answers (0)