cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic mapping

Former Member
0 Kudos

Hi All,

I am creating dynamic mapping of context between comp controller and view part by using the following link.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6fdae690-0201-0010-a580-d104b459...

-creating only one node and one attribute say "attr1" which has value "hi" dynamically.

-mapping dynamically to view.

The problem is I can able to print the value attribute "attr1" which is mapped from comp controller to view. But unable to print the value "hi" which is set in attr1.

Com Controller Code:

IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("dynamicNode1",null,true,true,false,false,false,true,null,null,null);

nodeInfo.addAttribute("attr1","com.sap.dictionary.string");

IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("dynamicNode1",IWDNode.LEAD_SELECTION);

IWDNodeElement nodeElem = node.createElement();

nodeElem.setAttributeValue("attr1","hi");

node.addElement(nodeElem);

If i bind this attrinfo to an UI element, I can see the output "hi".

But I dont want to create an UI element. Just want to display the value from that attribute which is mapped from comp controller to view dynamically.

View Code:

IWDNodeInfo compNodeInfo = wdThis.wdGetExportexSampleCompController().wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode1",IWDNode.LEAD_SELECTION).getNodeInfo();

IWDNodeInfo localNodeInfo1 = wdThis.wdGetAPI().getContext().getRootNodeInfo().addMappedChild("dynamicNode2",null,true,false,false,null,false,true);

localNodeInfo1.setMapping(compNodeInfo,true);

localNodeInfo1.addAttributesFromDataNode();

Iterator itr = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getNodeInfo().iterateAttributes();

while(itr.hasNext()){

IWDAttributeInfo attrInfo = (IWDAttributeInfo)itr.next();

msgMgr.reportSuccess(attrInfo.getName() + "attrname");

In the above code, attrInfo.getName()-gives the name of the value attribute. "attr1"

Similarly I need to display the value of that attribute.

Hope I have clearly explained my problem. Please suggest some logic but not the links.

Regards,

Subashini.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ayyapparaj,

Thanks for replying instantly. attrInfo is an object for interator.

Iterator itr = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getNodeInfo().iterateAttributes();

while(itr.hasNext()){

IWDAttributeInfo attrInfo = (IWDAttributeInfo)itr.next();

msgMgr.reportSuccess(attrInfo.getName() + "attrname");

}

So where should I replace with your code?

Former Member
0 Kudos

Hi,



Iterator itr = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getNodeInfo().iterateAttributes();
while(itr.hasNext()){
IWDAttributeInfo attrInfo = (IWDAttributeInfo)itr.next();
String str = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getElementAt(0).getAttributeValue(attrInfo.getName())
msgMgr.reportSuccess(attrInfo.getName() + "attrname");
msgMgr.reportSuccess(str);

}

Regards

Ayyapparaj

Former Member
0 Kudos

IWDNode node = wdContext.getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION);
IWDNodeElement element = node.getElementAt(0); /* assume it exists */
for (Iterator attributes = node.getNodeInfo().iterateAttributes(); attributes.hasNext(); )
{
  IWDAttributeInfo attribute = (IWDAttributeInfo) attributes.next();
  Object value = element.getAttributeValue(attribute.getName());
}

Armin

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Ayyapparaj&Armin,

Thanks for your instant replies and clarified my doubts.

Awarded points.

Thanks a lot.

Regards,

subashini.

Former Member
0 Kudos

Hi,

Yeah, view to view mapping is not possible. How about view1 to controller then to view2?

Former Member
0 Kudos

It should be controller->view1

controller->view2

Hope its clear.

Former Member
0 Kudos

Hi Armin&Ayyapparaj,

Thanks for your replies. I have got one more query.

Is it possible to create an attribute dynamically in one view and get it in another view?

Example:

I have 2 views say v1 and v2.

I am creating dynamic attribute&setting its value in v1 - attr1,"hi".

I want to get this attribute attr1 and its value "hi" in v2 through dynamic mapping. Please note that everything is dynamic(node creation,attr creating,mapping).

Is this possible?

Hope I am clear with the query.

Former Member
0 Kudos

Hi,

Is it possible to create an attribute dynamically in one view and get it in another view?

View to view mapping is not possible.

Only from controller to view.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

use

Assuming 1 element is existing, other wise it will result in nullpointer exception


wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getElementAt(0).getAttributeValue(attrInfo.getName())

Regards

Ayyapparaj