cancel
Showing results for 
Search instead for 
Did you mean: 

difference between

Former Member
0 Kudos

Can someone clearly explain in words, what exactly is the difference between wdContext() and wdThis()

.When shud we use which one while we write the coding for the view and controller ??

Thanx in advance

Edited by: pankaj mathur on Sep 10, 2008 2:43 PM

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Pankaj,

wdContext refers to the root Context node of the component (e.g Views or Controllers)

wdThis refers to the component itself

Regards,

Siva

Former Member
0 Kudos

Cud u plz explain in a little more detail

What do u exactly mean by the node of the component??

Is this true that wdThis is generally used during the View coding when the data is available at the view context.

Whereas wdContext() is used when the data is available at the controller context ??

Plz explain

Points will be given

Thanx

former_member187439
Active Participant
0 Kudos

During coding, the most generic situations where these 2 are used are,

1. you have to use wdThis if you want to call an action, a method, or a event handler which is defined either in your view or in your controller.

2. you have to use wdContext if you want to "get" or "set" values from or to the "node" and "attribute" (it could be a model node, model attribute,value node or value attribute).

so your next question:

Is this true that wdThis is generally used during the View coding when the data is available at the view context. Whereas wdContext() is used when the data is available at the controller context ??

- this is not true, if you understand the above mentioned 2 points.

former_member197348
Active Contributor
0 Kudos

Hi Pankaj,

wdContext refers to the root Context node of the component i.e Context of Views or other Controllers

wdThis refers to the component itself ( Views or other Controllers)

When should we use which one while we write the coding for the view and controller ??

Whether in View or Controller,

if you want to refer any context attributes or nodes we use wdContext.

//to refer node

wdContext.node<nodename>() ;

//to refer attribute

wdContext.currentContextElement().get<attributename> ();

If you want to use any of the component's methods we use wdThis.

//to call a method

wdThis.<methodname>();

// you can get reference of the component controller in the view //like

wdThis.wdGet<Controllername>();

Regards,

Siva

Answers (1)

Answers (1)

Former Member
0 Kudos

for information on wdthis

refer this thread