cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to call methods of one view from another

Former Member
0 Kudos

Hi experts,

I am new to webdynpro.I am having some requirement in which I need to call methods of one view from some other view of same component .So is there any way to do this.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Pradeep,

You can define the method in the componentcontroller.

As you have available the ref. of component controller as "WD_COMP_CONTROLLER" in all views,

the method can be called using the reference.

Former Member
0 Kudos

Ya that I can do but Let me explain you my exact requirement.I am doing validation using method check_mandatory_attr_on_view in the class cl_wd_dynamic_tool Which take exporting parameter as Viewcontroller for that I have to write method in the view for which I am validating User Input. But this method will call on button click which is on other view.

So I need to call it from buttonsview.

Former Member
0 Kudos

Hi

You can go to the view containing the button Lets say view1 and in the properties tab add comp usage of the window to which the other view2 is bound .

Now go to the methods tab in view1 call the method you want from view 2

.It will be good if you use the code wizard to call the method of the used controller of view1.

Reward points if helpful

Thanks in advance

Former Member
0 Kudos

Dear Pradeep,

This will solve your problem......( plz 1st read everything ..)

There are 2 views :

i) Mandatory Attributes ' view(V1)

ii) Button' s View..(V2)

1. Create a method in Component Controller.( M1).

2. Goto V2 . In the Action Handler method of Button , call method M1 of component controller.

3. Write your Code in M1 instead of V2 method.

4. Create an EVENT ( E1 ) in component controller.

5. Fire this event from M1 before executing Action Code.

6. Now Add the event handler method of E1 in V1 ( i.e. Mandatory attributes view. ) ..........clear????? .. set "METHOD TYPE" = Event Handler. instead of Method.

7. In this event handler method in V1 , write the "check_mandatory_attribute_view" method.

8. use necessary flags..

Regards ,

Aditya.

Former Member
0 Kudos

Hi Pradeep,

One more way you can handle this is:

There are 2 views :

i) Mandatory Attributes ' view(View1)

ii) Button' s View..(View2)

1. In componentcontroller's attribute tab, declare an attribute o_view1 type ref to if_view1. Make it as Public Attribute.

2. You can access this attribute from View1, so in WDOINIT method of view1 you can assign:

wd_comp_controller->o_view1 = wd_this.

3. Now you can write the validation method in component controller as you are available with refrence of viewcontroller of view1 in attrubute wd_this->o_view1 in any component controller method.

Former Member
0 Kudos

Thanks...

Former Member
0 Kudos

Thanks I guess it will work..