cancel
Showing results for 
Search instead for 
Did you mean: 

define a variable and access to its value or change in WebDynpro

Former Member
0 Kudos

Dear All!

How can I define with WebDynproin a class a boolean variable

assign a value e.g false.

boolean appeared = false;

And later in another class it will be aasigned to the

value "true" if a coditions is fullfilled.

Please notice both classes are in the same

Development Component

if(.....)

{

appeared = true;

}

regards

sas

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Sas,

The best way is to define the boolean variable as context attribute in the classes wherever you want and finally in Component Controller and map them all. Then the varable becomes global to DC. You can set this in your class using

wdContext.currentContextElement().setAppeared(true);

or else if you want to define only class variable,

you must define it in block

//@@begin others

//@@end

But this usage is not much recommneded by SAP. The scope of the varable is only this view is visible.

regards,

Siva

Message was edited by:

Siva Rama Krushna

Answers (3)

Answers (3)

Former Member
0 Kudos

Dear All!

To clearify misunderstandings.

Suppose there might be a variable (boolean).

This variable is in the controller class. And now I would like

access this variable from the view class.

bye

sas

Former Member
0 Kudos

Hi,

Open the property sheet for the view and in the "Required Controllers" section add the appropriate Controller class. Then you can access the controller class from the view using something like:

wdThis.wdGet<Controller Name>Controller.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

Ideally you can acheive this using context attributes.

IF you still want to work with classes

1)Create a class , specify a constuctor and set and get method for the property.

2)In the init of the controller create an instance of this class

3)Create a method in the controller which returns the instance of this class.

Next

1) Create a singleton class

2)Access it from two different places.

Regards

Ayyapparaj

Former Member
0 Kudos

Ok but how can I access to this variable from out of the other class.

Imagine there are classes:

Class1

has

boolean appeared = false;

Class2

?????getAppeared();

sas

former_member197348
Active Contributor
0 Kudos

Hi Sas,

In Web Dynpro class to class data transfer is only possible through context mapping.

If a variable is defined in

//@@begin others

//@@end you need to use the context varable to pass the value of this varable.

Taht's why use context variable

If you want to pass the variable to another view. Do This.

In View1 create a context attribute appeared of type boolean.

<b>copy</b> this, go to context tab of View2 and Component Controller <b>paste</b> this. Now in View1 context tab ,select this right click select editContextmapping,

you can map to Controller, do same for View2 also.

if you want to set this attribute,

use this code

wdContext.currentContextElement().setAppeared(false);

if you want to get this attribute.use this code

wdContext.currentContextElement().getAppeared();

if this does not serve your requirement,just give you exact requirement.

Siva