cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic context mapping

Former Member
0 Kudos

Hi

Can context mapping be done dynamically? If so can anyone give me a sample code.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

yes context mappin can b done dynamically

see this

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ...

Check this link..

Hop this will help u..

Urs GS

Former Member
0 Kudos

Hi Vidyadhar,

Consider You want to do Dynamic Context Mapping between Component Controller and the View Controller

You can use this kind of code....

In the component controller <b>wddoInit()</b> Method write this piece of code


IWDNodeInfo India = wdContext.getNodeInfo().addChild("India",null,true,true,false,false,false,true,null,null,null);
	IWDAttributeInfo City = India.addAttribute("City" , "ddic:com.sap.dictionary.string");	
	IWDNode NodeIndia = wdContext.getChildNode("India",0);
	NodeIndia.getCurrentElement().setAttributeValue("City","Mumbai");

Now create and context map a <b>Node</b> in the <b>View Controller</b>

Write this piece of code in the View controller <b>wddoInit()</b> Method

	IWDNodeInfo NodeInfo = wdContext.getNodeInfo().addMappedChild("Bharath",null,true,true,false,null,false,true);	
	IWDNodeInfo CompNode = wdThis.wdGetDynMapController().wdGetContext().getNodeInfo().getChild("India");
	NodeInfo.setMapping(CompNode,true);
	IWDAttributeInfo AttInfo = CompNode.getAttribute("City");    
	IWDAttributeInfo NewAtt = NodeInfo.addMappedAttribute("City",".DynMap.India.City"); //Please Note that DynMap is the Name of the Component, India is the Node and the City is the attibute
	IWDNode N1 = wdContext.getChildNode("Bharath",0);
	wdComponentAPI.getMessageManager().reportSuccess(N1.getCurrentElement().getAttributeAsText("City"));

When the value is set for an attribute in the Component Controller, you will be able to access it from the View Controller

Regards,

Mathan MP