cancel
Showing results for 
Search instead for 
Did you mean: 

Acessing a view context element

Former Member
0 Kudos

Hi,

How do we acess a view context element from another view.

I mean in ViewA I had a context element, say grade.

I need to access this context element in another view say View B.

Regards

MQ

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

You need a tutorial

For Netweaver 2004: [Web Dynpro Java Sample Applications and Tutorials for SAP NetWeaver 2004|https://www.sdn.sap.com/irj/sdn/nw-wdjava?rid=/webcontent/uuid/503f22f6-b978-2a10-bf97-ddc21267e752] [original link is broken];

For NetWeaver 7.0: [Tutorials & Samples for Web Dynpro Java|https://www.sdn.sap.com/irj/sdn/nw-wdjava?rid=/webcontent/uuid/00b64d9f-fea2-2910-c988-ee2544047f8c] [original link is broken];

But to answer your question... you have to create a context element on the Component Controller, then bind it to the element context on both views. To bind it to the view open the diagram view and draw an arrow from the view to the controller and drag the elements.

Regards

Former Member
0 Kudos

Hi,

You can create a context attribute in the component controller.

Map this context attribute to both the contexts of view A and View B

Set some value in the context attribute in View A.

This value can be accessble in View B as well..

Regards,

Saleem

Former Member
0 Kudos

Hi,

For example if you have a context attribute called "grade" in ViewA. And you want to access the same attribtue in the ViewB.

1.Create the same attribute in Component Controller and ViewB aswell.

2. Now go to the properties tab of ViewA and click on Add button. It shows the all the controllers. Here select your Component Controller.

3. Now right click on context attribute "grade" of View and select "Edit Context Mapping".

4. Here select the "grade" attribute of Component Controller earlier you created.

Repeat the steps 2,3,4 for ViewB also.

So you can access the value of context attribute "grade" in ViewB also.

(Or)

Create the context attribute "grade" in Component Controller first.

Now go to the DataModler diagram of Comopnent by right clicking on the Component.

Here drag the data link between the ViewA and Component Controller. And drag and drop the "grade" context attribute from Comp Controller to ViewA.

Similarly drag and drop from Comp Controller to ViewB also.

So you can access the value of context attribute "grade" in ViewB also.

Regards,

Charan

Regards,

Charan

Former Member
0 Kudos

Hi,

Without component controller, can we do by accessing the view.

I know that we can do with component controller

Regards

MQ

Former Member
0 Kudos

Hi,

View is private. A View can't access the runtime data of another View directly without Compnent Controller.

Component Controller is public to all the Views in the Component.

Alternatively you can keep your value in client session. So that you can access that throughout the application within that session using the below code.


WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE,"KEY","Value");
WDScopeUtil.get(WDScopeType.CLIENTSESSION_SCOPE,"KEY").toString();

Regards,

Charan

Former Member
0 Kudos

Hi,

Can we set an context element of a component controller in the view without mapping.

I need to use code to set a value to the context of a component controller

Regards

MQ

Former Member
0 Kudos

Hi,

Use this below code:


wdThis.wdGetCompController().wdGetContext().currentContextElement().getGrade();
wdThis.wdGetCompController().wdGetContext().currentContextElement().setGrade("Value");

Before trying this code: Do this:

Go to the properties tab of View and click on Add button. It shows the all the controllers. Here select your Component Controller.

Regards,

Charan

nitin_mahajan2
Contributor
0 Kudos

The sole purpose of doing mapping is to avoid coding to set the values. If you dont do mapping you can have elements in the controller context and view context and get / set the values of each context.

What exactly are you looking for?

Regards,

Nitin

nitin_mahajan2
Contributor
0 Kudos

Sri, the solution is ok, but i would suggest not to use the client session or application session variables untill there is no other optimal solution.

The use of these variables should be minimum and optimum.

I think it would be good to first understand what the exact requirement is.

Regards,

Nitin

Edited by: Nitin Mahajan on Jun 16, 2009 6:32 PM

Former Member
0 Kudos

Why can't you use context mapping?

Armin