cancel
Showing results for 
Search instead for 
Did you mean: 

Form field validation messages in pop-up window

Former Member
0 Kudos

Hi all,

I am using the create_window method from if_wd_window_manager to generate a pop-up window. The pop-up window contains a view with two radio button groups. When the user presses the OK button in the pop-up window, I want to validate the users entries (entry in the rbg is required and certain combinations are not allowed). The error message should be displayed in the pop-up window.

To achieve this, in method WDDOBEFOREACTION I run method cl_wd_dynamic_tool=>check_mandatory_attr_on_view to check for mandatory fields (both radio button groups have state required) and I use the following code to generate an error message when a certain combination of radio buttons is selected:

l_message_manager->report_error_message( exporting
    message_text       = 'message'(e01)
    cancel_navigation = abap_true ).

The check is executed correctly and the action that I have assigned to the OK button is not excuted, but my pop-up window is closed when the checks fail. check_mandatory_attr_on_view does not generate any message at all and the message I generate using the message manager is displayed on the initial screen.

How can I prevent the pop-up window from being closed when validation fails?

Thanks!

Patrick Angevare

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

When ever you are checking the mandratory feilds then,

if they are initial then set the flag to X.

Implement the CLOSE button and its' action for the popup.

If flag eq space.

*clear if any messages are there
     CALL METHOD wd_comp_controller->gref_msg_manager->CLEAR_MESSAGES
        EXPORTING
          INCLUDING_PERMANENT_MSG = ABAP_false
          ONLY_PERMANENT_MSG      = ABAP_FALSE.
*close the popup.
          CALL METHOD wd_comp_controller->GREF_W_POPUP_SPLIT->SET_CLOSE_IN_ANY_CASE
            EXPORTING
              CLOSE_IN_ANY_CASE = abap_true.

      CALL METHOD wd_comp_controller->GREF_W_POPUP_SPLIT->CLOSE.
endif.

CLOSE button code -

IF wd_comp_controller->gref_w_popup_split IS NOT INITIAL.
      CALL METHOD wd_comp_controller->gref_msg_manager->clear_messages
        EXPORTING
          including_permanent_msg = abap_false
          only_permanent_msg      = abap_false.

      CALL METHOD wd_comp_controller->gref_w_popup_split->set_close_in_any_case
        EXPORTING
          close_in_any_case = abap_true.
      CALL METHOD wd_comp_controller->gref_w_popup_split->close.
    ENDIF.                      "   if wd_comp_controller->GREF_W_POPUP is not initial.

Have you used Modal popup or create_popup_to_confirm method for creating a popup.

Regards,

Lekha.

Former Member
0 Kudos

Thanks Lekha,

I am a step closer now but I still cannot seem to get it working.

In use the following code in the main view I call the pop-up window:

DATA: context_node              TYPE REF TO if_wd_context_node,
             lr_popup                       TYPE REF TO if_wd_window,
             lr_view_controller        TYPE REF TO if_wd_view_controller,
             lr_api_comp_controller TYPE REF TO if_wd_component,
             lr_window_manager    TYPE REF TO if_wd_window_manager.
             l_api                              TYPE REF TO if_wd_view_controller,
            l_window_ctlr               TYPE REF TO if_wd_window_controller.

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

  lr_popup = lr_window_manager->create_window(
              window_name       = 'POP_UP'
              title             = 'Nieuw record toevoegen'
              close_button      = abap_true
              close_in_any_case = abap_false
              button_kind       = if_wd_window=>co_buttons_okcancel ).

The ok button is assigned to an actionmethod in which I check if there are any messages in the message manager:

IF l_message_manager->is_empty( ) EQ abap_true.

 ENDIF.

How should I call the close or set_close_in_any_case method for the pop-up window between the if statements?

Thanks a lot!!

Patrick

Edited by: Patrick on Aug 12, 2009 1:43 PM

Former Member
0 Kudos

Hi Patrick,

As this is the modal popup, there is a close button .

Now in the ACTIONS tab try to create an action for CLOSE.

Once you get the window reference,

wd_comp_controller->gref_w_popup_split type ref to IF_WD_WIINDOW.

SET_ON_CLOSE_ACTION

SET_CLOSE_BUTTON

CALL METHOD wd_comp_controller->gref_w_popup_split->set_close_button
        EXPORTING
          close_button = abap_true.

      CALL METHOD wd_comp_controller->gref_w_popup_split->set_on_close_action
        EXPORTING
          view        = wd_comp_controller->gref_v_controller_split
          action_name = wd_assist->gc_close_split.

"Action Name

In the CLOSE action -

IF wd_comp_controller->gref_w_popup_split IS NOT INITIAL.
      CALL METHOD wd_comp_controller->gref_msg_manager->clear_messages
        EXPORTING
          including_permanent_msg = abap_false
          only_permanent_msg      = abap_false.

      CALL METHOD wd_comp_controller->gref_w_popup_split->set_close_in_any_case
        EXPORTING
          close_in_any_case = abap_true.
      CALL METHOD wd_comp_controller->gref_w_popup_split->close.
    ENDIF.                      "   if wd_comp_controller->GREF_W_POPUP is not initial.

Regards,

Lekha.

Former Member
0 Kudos

Solved, thanks Lekha!!

Answers (0)