cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic View Context Nodes, Attributes & Element

Former Member
0 Kudos

Hello All,

I am trying to create Dynamic View Context Nodes in webDynPro. I used the tutorial <i><b>"Dynamic Programming in Web DynPro"</b></i>.

<b>The code for creating new node (in the tutorial) is:</b>

IWDNodeInfo node= wdContext.getNodeInfo().<b>addChild</b>("DynamicNode",null,true,true,false,false,false,true,null,null,null);

This method is <b>deprecated</b> and somehow i was able to use new method as:

IWDNodeInfo node = wdContext.getNodeInfo().<b>addChild</b>("DynamicNode",null, true,CMICardinality.ONE_TO_MANY,CMICardinality.ONE_TO_MANY, false, null);

<b>For Creating a dynamic Attribute:</b>

IWDAttributeInfo fieldName = schemaNode.addAttribute("AttrID","com.sap.dictionary.string");

I am confused in using this code and have the <b>following questions..</b>

<b>Q1.</b> What is the difference between <b>IWDNodeInfo</b> and <b>IWDNode</b> ?

<b>Q2.</b> Are we creating actual Context nodes here ?

<b>Q3.</b> What is the difference between <b>Context Nodes</b> and <b>Context Elements</b> ? [ As of now i visualize Context Node as to define basic structure of context and context element to hold actual values.]

Please reply soon...:-(

Regards,

Aayush

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Q1: IWDNodeInfo is metadata (description of data), IWDNode is a list of actual data

Q2: Yes and no. You are creating metadata. But WD automatically creates data based on this definition for you.

Q3: context Node is a list of context NodeElements

What SP are you using? This method in not deprecated even in NW04s.

P.S. "List" here is not java.util.List, but just logical term to define ordered set of entries with the same type.

Former Member
0 Kudos

Hello Valery,

Thanks a lot. This solves my problem to an extend. But a small doubt:

If i cast IWDNodeInfo object to IWDNode object do i get the handle of that Context Node.

Regards,

Aayush

Former Member
0 Kudos

hi,

This is how you create the context node.

IWDNodeInfo node= wdContext.getNodeInfo().addChild("DynamicNode",null,true,true,false,false,false,true,null,null,null);

To get a handle of that node we generally use

wdContext.node<name>;

And you cant typecast nodeinfo to node.What do you want to do.

Tel us the requirement !

Regards

Bharathwaj

Former Member
0 Kudos

But how can we get a handle of that node by using

wdContext.node<name>;

We have created that node dynamically so we dont have any such method <b>.node<name></b> available.

Regards,

Aayush

Former Member
0 Kudos

To explain Bharathwaj answer:

1. You have one node always available, it is exposed via wdContext variable (the root).

2. If you not creating nodes dynamically but using designer instead, WD generates you handful methods to access sub-nodes: say, wdContext.nodeEmployees(), wdContext.currenEmployeesElement().nodeProjects()...

3. If you are creating nodes dynamically at run-time these methods are not generated, and you have to access nodes in dynamic way:


final IWDNodeInfo niEmployees = wdContext.getNodeInfo().addChild("Employee", /*..*/);
final IWDNode nEmployees = wdContext.getChild(niEmployees.getName(), IWDNode.LEAD_SELECTIOn);

VS

Former Member
0 Kudos

Hi,

You can use wdContext.getChildNode("Node name",0);

WOW ! Quite a race..! And I am last !NICE TO SEE !

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Hello All,

How do i create an Attribute to the dynamically created Node ?

I tried using code:

<b>IWDAttributeInfo fieldName = myNode.addAttribute("Attr0",

"com.sap.dictionary.string");</b>

But not sure whether it creates <b>Attribute</b> of <b>AttributeInfo</b> ..

Please explain IWDAttribute.

Regards,

Aayush

Former Member
0 Kudos

Hi,

If there is a attribute it will have an attribute info .

You cant create attributeinfo.

Addattribute will add an attribute!

Go to NDS help and check.It will have all the details .

When you say ctrl+space and get a function the help related to the function comes as a tooltip.

Message was edited by: Bharathwaj R

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try with wdContext.getChildNode();

or

wdContext.getNodeInfo().getChild("");

Regards, Anilkumar

Former Member
0 Kudos

Hello All,

Thanks a lot. This works.

Regards,

Aayush

Former Member
0 Kudos

HI,

Q1. What is the difference between IWDNodeInfo and IWDNode ?

Nodeinfo gives the metadata information of the node like cardinality ,selection property etc.,

Node actually creates a structure and adds attributes to it which can store values.

Q2. Are we creating actual Context nodes here ?

Yes ,You are.

3. What is the difference between Context Nodes and Context Elements ?

ya you are right ! Context nodes just hold a list of elements with the structure defined by you. The values for each elements is stored in its attributes

Regards

Bharathwaj

Former Member
0 Kudos

Hello Anilkumar, Bharathwaj

How IWDNode can be used then? can i type cast the IWDNodeInfo object which i created to IWDNode object ?

Is there any other way to create IWDNode without typecasting ?

Regards,

Aayush

Former Member
0 Kudos

Hi,

1. The metadata information of the controller context is represented at runtime in the objects of the types IWDNodeInfo and IWDAttributeInfo.

2.yes

3.Please refer to this for details

http://help.sap.com/saphelp_nw04/helpdata/en/76/98384162316532e10000000a1550b0/frameset.htm

regards, Anilkumar