cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with variables wdThis and wdContext.

Former Member
0 Kudos

Hello,

My English is bad, sorry.

Not yet mastered the use of variables wdThis, wdContext, wdControllerAPI and wdComponentAPI. Two questions:

From a view1 method1 and method2 I can call a View2 found in the same 'Web Dynpro Components "?

Since a method of a view, as I can access the properties of their UI Elements, such as access to modify the 'text' of the title of a UI Element Tray?

Regards,

Ruben Gutierrez

Accepted Solutions (1)

Accepted Solutions (1)

former_member218672
Active Contributor
0 Kudos

Hi Ruben

First create an outbound plug from the View A to View B and similarly create an Inbound plug from View B to View A. On action of the Link to Action UI element, write the following code:

wdThis.wdFire<plugname from A to B>();

this will navigate from one view to another. For navigating back to View A, write the same code:

wdThis.wdFire<plugname from B to A>();

Also, if you have nwds installed in your system, open it > then go to help > sap web as documentation > sap webdynpro application > open it and here you'll find create your 1st application in webdynpro java...........go thru it...

hope it helps.

Regards,

Sen

Answers (5)

Answers (5)

Former Member
0 Kudos

Regarding your first question:

The steps for making a cross-view method call are:

1.- Create an event in the component controller.

2.- Create a method in the component controller wich fires the event.

3.- In view 2, create an event handler wich suscribes to the component controller event.

4.- In view 1, call the component controller method.

Despite I don't know your requirements, I would suggest not using this frequently. Generally views shouldn't have much code and business functionallity should be at the component controller level. You can achieve almost everything through the component controller, binding attributes to the views.

Best regards, Aldo.

Former Member
0 Kudos

Thanks to Nizamudeen and Aldo.

Good answers. Problem solved.

I will consider your advice Aldo.

Thanks to all,

Gerards, Rubén Gutiérrez

Former Member
0 Kudos

Rubén, this are the steps for dynamically modifying a Tray header from another view. Lets consider we are working with view1 and view1. View2 contains a Tray element and view1 contains a button which when pressed, should change the Tray element header.

1.- Add a context attribute to the component controller, name it trayHeader.

2.- Link this attribute to view2.

3.- Link the attribute in view2 to the text property of the Tray_Header element.

4.- Create a method in the methods tab of the component controller with a string parameter, name the method modifyTrayHeader and the parameter header. Code the method:


  public void modifyTrayHeader ( java.lang.String header)  {
    //@@begin modificarTituloTray()
	  wdContext.currentContextElement().setTrayHeader(header);
    //@@end
  }

5.- Link view1 to the component controller (it isn't necessary to link any attribute).

6.- In view 1, code the action method for the button:


    wdThis.wdGet<ComponentName>Controller().modifyTrayHeader("My header");

That's it!

An easier option would be to link the atribute from the component controller to the view1 and instead of taking steps 4, 5 and 6, just modify the attribute in the view1 with this code:


wdContext.currentContextElement().setHeader("My header");

The attribute header of view1 is linked to the one in the component controller wich is linked to view2 and in turn linked to the text property of the Tray_Header element.

Best regards,

Aldo.

Former Member
0 Kudos

Thanks to Nizamudeen, Prodyut and Deepak .

About first question, sorry but I have explained it wrong. Do not want to navigate from the view1 to the view2. From view1 want to call a method2 of the view 2.

About second question, thanks to Deepak. The system you propose, it's ok.

Thanks for your answers,

Regards,

Rubén Gutiérrez

Edited by: bifusion on Dec 23, 2010 11:42 AM

former_member185879
Active Contributor
0 Kudos

Hello Bifusion,

1. It is not possible to call method of view2 in view1. What you can do is, write a method in Component Controller and implement whatever you want to do in view2 and then you call that method from view1.

2. As usual by setting value to the context attribute, we can change any titles we want.

Revert for any queries.

Regards

Nizamudeen SM

Former Member
0 Kudos

HI,

For your clarification:

1.You can navigate b/w views by using fire plug concepts.

2. You can change the header text dynamically by binding it to a context attribute and then mapping the same context attribute with different views/compoent controller.

3. You should create your business logic in component controller and reuse it in different views.

There are ample documents available on above topics in sdn and help.sap.com please check the same.

Regards

Deepak

former_member185879
Active Contributor
0 Kudos

Hello Bifusion,

Can you explain bit more on your requirements?

Are you asking how to access one view UI element property from another view? or are you asking how to set the title for UI Element Tray?

Regards

Nizamudeen SM