cancel
Showing results for 
Search instead for 
Did you mean: 

HOw to pass Dynamic attributes from one view to another view.

Former Member
0 Kudos

Hi experts,

I have one static node in the controller.I mapped this static node SN with view1 and view2.

Now i created 3 dynamic attributes for this static node SN in the view2. Now i want to get these dynamic attributes in view1.

Please suggest me how to get the dynamic attributes from view2 to view1.

i tried with :-

wdContext.nodeSN.currentSNElement.getAttribute().

-


I tried with this code as well:-

Iterator it=wdContext.nodeNodeSN().getNodeInfo().iterateAttributes();

do{

String name=((IWDAttributeInfo)it.next()).getName();

wdComponentAPI.getMessageManager().reportSuccess(name);

}while(it.hasNext());

-


Its not working.

Regards

-Sandip

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi experts,

I have one static node in the controller.I mapped this static node SN with view1 and view2.

Now i created 3 dynamic value attributes for this static node SN in the view2. Now i want to get these dynamic value attributes in view1.

i tried with :-

wdContext.nodeSN.currentSNElement.getAttribute().

-


I tried with this code as well:-

Iterator it=wdContext.nodeNodeSN().getNodeInfo().iterateAttributes();

do{

String name=((IWDAttributeInfo)it.next()).getName();

wdComponentAPI.getMessageManager().reportSuccess(name);

}while(it.hasNext());

-


Its not working.

Please suggest me how to get the dynamic value attributes from view2 to view1.

Regards

-Sandip

Former Member
0 Kudos

Hi,

Do you create using AddAttribute method in the view2?

Use AddMappedAttribute instead of addAttribute.

for how to use AddMappedAttribute, please goto this link

http://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/progmodel/api/IWDNodeInfo.html#ad...

Just suggestion,

Create the attribute (using AddAttribute) in controller, instead of in the View.

Then every View you need to do AddMappedAttribute.

Like this:

In Controller (wdDoInit):

wdContext.nodeTest().getNodeInfo().addAttribute("attr1", "ddic:com.sap.dictionary.string");

wdContext.nodeTest().getNodeInfo().addAttribute("attr2", "ddic:com.sap.dictionary.string");

IWDNodeElement elemGlb = wdContext.nodeTest().createElement();

elemGlb.setAttributeValue("attr1", "ABCDEF");

wdContext.nodeSurvey().addElement(elemGlb);

In the View (wdDoInit):

wdContext.nodeTest().getNodeInfo().addMappedAttribute("attr1InView", "attr1");

wdContext.nodeTest().getNodeInfo().addMappedAttribute("attr2InView", "attr2");

In the View (wdDoModifyView)

IWDGroup group = (IWDGroup) view.getElement("InputGroup");

IWDLabel theLabel = (IWDLabel)view.createElement(IWDLabel.class, "lbl1");

theLabel.bindText("text.attr1InView");

group.addChild(theLabel);

Regards

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Sandip

I agree with the bro above, and also addMappedAttribute is a quick way to solve ur requirement. But as i suggested, how about create all of your mapped nodes and attributes in controlers?

in controler:

create node and create attributes

in viewer:

mapping node and all its attributes

actually, u can define each viewer new attributes in ur mapped node attributes with attributeAccessor.

if u want the code example, please contact me.

Former Member
0 Kudos

Hi David,

Tha mapping for the node N is done :-Controller -> View 1

and Controller -> View 2.

So node N is available in the context of view2.Now i created Dynamic value attributes(through code).,i repeat its not a static value attribute.

Now since this is not a static attribute,it will not get reflected in the contyext of View1.

Now what i want is ,i want to get those Dynamic attributes from View2 to view1.I think I m clear abt the requirement.

Please suggest .

Regards

-sandip

Former Member
0 Kudos

Hi Sandip,

I don't really understand your requirement.

I assume you already create proper mapping between Controller -> View 1

and Controller -> View 2

My question:

1. When and how you add the element to the node?

usually I use this code (please check with your webdynpro intellisense)

IPrivateView1.IPrivateSNElement elem = wdContext.nodeSN.createElement();

wdContext.nodeSN().addElement(elem);

2. To get current Element, I only use wdContext.currentNodeElement.getZ***()

Z*** is your Attribute Name.

Former Member
0 Kudos

Hi,

Still this thread is not answer properly.

Can any one please suggest how to pass dynamic attribute values from one view to another view.

I tried with all possibe ways.Its urgent for me.

Please suggest.

Regards

-Sandip

Former Member
0 Kudos

Hi,

refer the thread

Regards,

Sudhir