cancel
Showing results for 
Search instead for 
Did you mean: 

View_Controller in methos of componentcontroller

former_member429661
Participant
0 Kudos

Hi all,

how can i define buttons in an method of an componentcontroller ?

lr_api_comp_controller = wd_this->wd_get_api( ).
    lr_window_manager = lr_api_comp_controller->get_window_manager( ).


*   POPUP Window vorbereiten
    lr_popup = lr_window_manager->create_window(
    modal               = abap_true
    window_name         = 'W_SAVE'  
    title               = 'Speichern der geänderten Daten'
    close_button        = abap_true
    button_kind         = if_wd_window=>co_buttons_okcancel
    message_type        = if_wd_window=>co_msg_type_question
    close_in_any_case   = abap_true ).


*   Buttons definieren und deren Aktionen
    lr_view_controller = wd_this->wd_get_api( ). "Here is the Problem 
    imp_view_controller = wd_this->wd_get_api( ).

    lr_popup->subscribe_to_button_event(
    button = if_wd_window=>co_button_ok
    button_text = 'Seichern'
    action_name = 'CHANGES_YES'
    action_view = lr_view_controller ).

    lr_popup->subscribe_to_button_event(
    button = if_wd_window=>co_button_cancel
    button_text = 'Nicht speichern'
    action_name = 'CHANGES_NO'
    action_view = lr_view_controller ).

*   POPUP Window aufrufen
    lr_popup->open( ).

Errormessage:

The result of the functional method isn't possible to convert to the type to LR_VIEW_CONTROLLER.

Other method "CREATE_POPUP_TO_CONFIRM" throws the same error.

Any idea ?

Thanks in avance.

--Bernd

Edited by: Bernward Henkel on Sep 6, 2010 4:07 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Bernd,

Are you trying to access the view of the component ?

Could you please elaborate what would you like to achieve as a end result.

Anurag

former_member429661
Participant
0 Kudos

Hi Anurag,

i want to save changed data in a method of a the componentcontroller, because i called these method from different methods of different views.

In the methos of the componentcontroller i want to create a window to show all changed data. That works, but i cant' define the button-action for that new created window.

In the button-action of the new window i want to save the data which are stored in the context of the componentcontroller.

Hope that sound's a little bit clearer.

--Bernd

Edited by: Bernward Henkel on Sep 6, 2010 5:20 PM

Former Member
0 Kudos

Hi Bernd,

wd_this->wd_get_api( ). this statement would give you reference to component not the view.

take a variable of TYPE REF TO if_wd_component.

I believe, you have called a window with a view inside it, you have used the ui elements in the view to show the changes to the use and you have not used buttons explicitly in the samw view rather you have used the buttons on the windows.

Anurag

Edited by: Anurag Chopra on Sep 6, 2010 9:35 PM

former_member429661
Participant
0 Kudos

Hi Anurag,

ok... but how can i "connect" button "if_wd_window=>co_button_ok" with an action "action_name = 'CHANGES_YES'" ?

--Bernd

Former Member
0 Kudos

Hi Bernd,

you need to pass the reference of the view where action is defined.

Anurag Chopra

ChrisPaine
Active Contributor
0 Kudos

Do binding in the WDDOINIT of your view (which is embedded into the window that you have launched.)

View logic should be separated from your controller logic in the MVC design - and this is a nice example of WDA trying to force you to do exactly that!

Answers (1)

Answers (1)

Madhu2004
Active Contributor
0 Kudos

HI,

As you are creating a window pop up you will always have an option top create buttons in the view embded in the window which is used for pop up.

Instead of standard buttons use the buttons created by you in the vie. Remove the standard buttons.

To rmove the standard buttons :

pass button_kind = if wd_window=>CO_BUTTONS_NONE in the create window method

on the buttons palced in you view write the code such that you call the component controller methods to update the data.

If you do it in the way in thaty case no need to subscribe to the button events.

Regards,

Madhu

Edited by: madhu reddy on Sep 7, 2010 10:52 AM