cancel
Showing results for 
Search instead for 
Did you mean: 

How to cancel popup-close when pressing OK Button

Former Member
0 Kudos

Hi all,

I have a disturbing question within WebDynpro.

What i want:

Keep the popup screen open when the inputfield is initial or if the value is wrong (on domain level). (3 values on domain level: low, medium, high)

What i did:

I Create a popup and subscribed an action to the ok button:

  wd_comp_controller->go_popup->subscribe_to_button_event(
   button = if_wd_window=>co_button_ok
   button_text = 'Ok'
   action_name = 'ADD'
   action_view = lo_view_controller
  ).

Within the onactionadd method i have placed a breakpoint but the program doesnt get past here if the inputfield is initial or if the inputfield has a bad value:

METHOD onactionadd.
ENDMETHOD.

When i leave the inputfield on the screen blank with

DETERMINED INPUT HELP: Z_MY_DOMAIN

TYPE OF INPUT HELP: fixed values for domains

Then when i push the Ok button it just closes the popup.

I Tryed to make the inputfield mandatory and use the next method within the WDDOBEFOREACTION:

  CALL METHOD cl_wd_dynamic_tool=>check_mandatory_attr_on_view
    EXPORTING
      view_controller  = lo_view_controller
      display_messages = abap_true
    IMPORTING
      messages         = lt_messages.

but even that diddnt work 😕

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

here lo_view_controller is the parent view controller reference. I think you have created a view with one input field and embedded in popup window.! if so, why don't you take a button in the popup view and do validation in onAction of that button.

Remove the okcancle button of popup window and create a button in the popup view and do validation.

hope this helps u.,

Thanks & Regards,

Kiran

Former Member
0 Kudos

Hi Kiran,

Yes the inputfield is within another view that i use as a popup, so i could use a self created button and close the popupscreen myself.

But by doing this i would have a different kind of layout and they would love to have same layout regarding the buttons and the little line that make some turns as you can see in the picture. Thats why my question regarding the cancelation of the popup. But if it is not possible this way, then ill create the buttons myself and try to represent the layout as possible

Thanks & Regards,

Michael

Former Member
0 Kudos

Hi micheal,

Pass the close_in_any_case parameter in create_window method as ABAP_FALSE.

and do your validations in your onactionOK method and close the window explicitly by coding,this would solve your problem.

data lo_window_manager type ref to if_wd_window_manager.
data lo_api_component  type ref to if_wd_component.
data lo_window         type ref to if_wd_window.
data lo_view           type REF TO if_wd_view_controller.

lo_view           = wd_this->wd_get_api( ).
lo_api_component  = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).

lo_window         = lo_window_manager->create_window(

                    window_name            = 'WIN2'
*                  title                  =
                  close_in_any_case      = abap_false
                    message_display_mode   = if_wd_window=>co_msg_display_mode_selected
*                  close_button           = abap_true
                    button_kind            = if_wd_window=>co_buttons_ok
                    message_type           = if_wd_window=>co_msg_type_none
                    default_button         = if_wd_window=>co_button_ok
                    ).

CALL METHOD LO_WINDOW->SUBSCRIBE_TO_BUTTON_EVENT
   EXPORTING
     BUTTON            = if_wd_window=>co_button_ok
*    BUTTON_TEXT       =
*    TOOLTIP           =
     ACTION_NAME       = 'OK'
     ACTION_VIEW       = lo_view
*    IS_DEFAULT_BUTTON = ABAP_FALSE
     .

**now create a attribute in your view lo_win type ref to if_wd_window.

wd_this->lo_win = lo_window.

lo_window->open( ).

And in your onactionOK method check your input field and close it if your validations are passed.

method ONACTIONOK .

     DATA lo_nd_inp TYPE REF TO if_wd_context_node.
     DATA lo_el_inp TYPE REF TO if_wd_context_element.
     DATA ls_inp TYPE wd_this->element_inp.
     DATA lv_attr LIKE ls_inp-attr.
*   navigate from <CONTEXT> to <INP> via lead selection
     lo_nd_inp = wd_context->get_child_node( name = wd_this->wdctx_inp ).

*   get element via lead selection
     lo_el_inp = lo_nd_inp->get_element(  ).

*   get single attribute
     lo_el_inp->get_attribute(
       EXPORTING
         name =  `ATTR`
       IMPORTING
         value = lv_attr ).

if lv_attr NE ''.
   wd_this->lo_win->close( ).
   endif.

endmethod.

Former Member
0 Kudos

Hi Reddy,

Thanks, i oversaw the "close_in_any_case" parameter when creating the window

This resolved my problem.

Kind Regards,

Michael

Answers (2)

Answers (2)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

What about binding the single field in  a node in component controller and then from popup window, acessing the same from component controller's node?

Former Member
0 Kudos

Hi Michael,

Where did you define the action ADD. It should be defined in the main view and not in the pop up view.

The method onactionadd will then only be triggered.

You can add the logic to validate the input and reopen the pop up if validaton fails in the method.

Hope it helps.

Regards,

Sayan