cancel
Showing results for 
Search instead for 
Did you mean: 

Class for IF_WD_CONTEXT_NODE

Former Member
0 Kudos

Hi Gurus,

I am new to WDA and OOPs . Some doubts

1 - Interface IF_WD_CONTEXT_NODE is implemented in which class.?

2 - What do you mean by attribute of an Interface (i.e WD_CONTEXT ) ?

TABLE_NODE = WD_CONTEXT->GET_CHILD_NODE( 'MY_TABLE_NODE' ).-- means what ?

3 - Why do we create objects of Interfaces and not classes that implement them ?

e.g data: TABLE_NODE type ref to IF_WD_CONTEXT_NODE.

4. Can i see the code for the CLASS that implements these INTERFACES ?

5. When and where are the objects for the classes created ?

(as in ABAP OOPs - CREATE OBJECT <varname> ).

Help me out.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

mohammed_anzys
Contributor
0 Kudos

Hi

The answers.

1. IF_WD_CONTEXT_NODE is implemented in the class CL_WDR_CONTEXT_NODE,

2.You could define attributes for an interface , so that it will be available to all teh classes implementing the interface.

3."The purpose of using interface is that you could store the instance of different implementing class according to the situation"

4.Yeah , you can go to teh CL_WDR classes and see it.

5.The objects are created in different places , for example if you go to CL_WDR_CONTEXT_NODE , CREATE method you could see the following code.

if node_info->_mapping_info-is_mapped is initial.

create object node type cl_wdr_context_node_val

exporting

parent_element = parent_element

node_info = node_info

node_name = node_name

context = context.

else.

create object node type cl_wdr_context_node_map

exporting

parent_element = parent_element

node_info = node_info

node_name = node_name

context = context.

endif.

Cheers

Anzy

Reward points if this answers to your question

Former Member
0 Kudos

HI Anzy,

I have still a doubt - how can we call an interface method directly using an interface variable .

eg: WD_CONTEXT->GET_CHILD_NODE( ) .

Can you send me simple example code explaining this?

mohammed_anzys
Contributor
0 Kudos

Hi Jimmy,

Let the context node be type of if_wd_context_node , and some where in the webdynpro the object will be created which means , an object of CL_WDR_CONTEXT_NODE. During the process it will be assigned to the interface

WD_CONTEXT , in the webdynpro ......so the interface will be holding an instance of CL_WDR_CONTEXT_NODE.

And we know that CL_WDR_CONTEXT_NODE. implements the interface IF_WD_CONTEXT_NODE.

So when you assign CL_WDR_CONTEXT_NODE instance to WD_CONTEXT ( of type IF_WD_CONTEXT_NODE )..Only those methods which are part of the IF_WD_CONTEXT_NODE will be available in WD_CONTEXT.

You can call this as a kind of type casting....:-) ..This is how the objects work in ABAP.

Thanks

Anzy

mohammed_anzys
Contributor
0 Kudos

Hi

let me add some more clarification .

A be an interface , having three method definitions.

B is a class which implements A ( So B will be having implementation of 3 methods of A as well as some additional methods of B , let it 2 ). so B will be having total five method implementation.

So when create an instance of B and assign that to a variable of A , only the 3 methods will be copied .

Thanks

Anzy

And you can't directly call from a variable of the interface unless an object is assigned to it.

Answers (2)

Answers (2)

former_member196517
Contributor
0 Kudos

Hi Jimmy,

Hera are some of the answers

1 - Interface IF_WD_CONTEXT_NODE is implemented in which class.?

CL_WDR_CONTEXT_NODE

2 - What do you mean by attribute of an Interface (i.e WD_CONTEXT ) ?

TABLE_NODE = WD_CONTEXT->GET_CHILD_NODE( 'MY_TABLE_NODE' ).-- means what ?

Here you are calling a method of IF_WD_CONTEXT_NODE to get a reference to a context node called as ' MY_TABLE_NODE' in your application. Once you get a refernce you can apply various operations on it. Like reading values or setting values of attributes of context node.

3 - Why do we create objects of Interfaces and not classes that implement them ?

e.g data: TABLE_NODE type ref to IF_WD_CONTEXT_NODE.

I cannot understand this question.. of course you can not create objects of the this class because it is a abstract class (reason being its non-completeness ) which therefore has this interface to use it and complete the implementation.

4. Can i see the code for the CLASS that implements these INTERFACES ?

. yes of course you can see the code.

5. When and where are the objects for the classes created ?

This are some basic of OOPS and i think you should go thru tutorials to draw this picture better.

Regards

Anuj

shwetars
Advisor
Advisor
0 Kudos

Hi Jimmy,

all implemetation classes in Web Dynpro begin with CL_WD prefix, so you can search for the same in se24.

its not mandatory to always use interfaces we can use classes as well. However the web dynpro wizard generates code that uses interfaces.

Yes you can check the code in the classes. For example the implementation class for the interface if_wd_context_node is cl_wdr_context_node.

Wd_context is a reference to the root node of your context. thus whenever you try to read any node in your context you should start with the root than traverse down the hierarchy.

Regards,

Shweta