cancel
Showing results for 
Search instead for 
Did you mean: 

How to restrict WDBEFOREACTION to perticular view only

former_member185241
Active Participant
0 Kudos

Hi All,

Let me explain what i am doing.

I have created a Login view and on before action i am validating the required field .

And one more view is created named Registration view  here also i am doing required field checking and data validation here.

Both view are designed in separate component.

Now i am creating third component , and on the view of this component i am taking tabstrip.

One tab of tabstrip contain login view and

Second view of tab strip contain Registration View. ( i have used component uses in third component)

Now what is the problem , when user click on Login button the WDBEFOREACTION Method of Registration view is also getting called and it is showing Error that Required Field is missing .

Is there any way to restrict WDBEFOREACTION Method to that view only on which it is created.

Thanks and Regards

Abhishek

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Abishek ...

please post the answer how u resolved..

former_member185241
Active Participant
0 Kudos

This is what i have written

METHOD wddobeforeaction .

*- Data declaretion

  DATA:  lt_msg TYPE cl_wd_dynamic_tool=>t_check_result_message_tab,

         lo_view_controller TYPE REF TO if_wd_view_controller,

         lo_api_controller TYPE REF TO if_wd_view_controller,

         lo_action TYPE REF TO if_wd_action.

  lo_api_controller = wd_this->wd_get_api( ).

*- Getting current action

  lo_action = lo_api_controller->get_current_action( ).

  IF lo_action IS BOUND.

    IF lo_action->name EQ 'LOGIN1'.

      lo_view_controller ?= wd_this->wd_get_api( ).

*- Checking mandatory field

      cl_wd_dynamic_tool=>check_mandatory_attr_on_view(

        EXPORTING

          view_controller = lo_view_controller

          display_messages = abap_true    "true that means it will display the message in message area

        IMPORTING

          messages = lt_msg ).

    ENDIF.

  ENDIF.

END METHOD

former_member185241
Active Participant
0 Kudos

Thanks to all .. Its working 🙂

former_member185241
Active Participant
0 Kudos

Thanks to all .. Its working 🙂

Former Member
0 Kudos

Hi Abhishek,

You can also try and make the Registration view with lifetime as 'When Visible'. Maybe this view won't be loaded when you are on the login page.

Otherwise, the solution entered by Kiran should definitely work..

Regards,

Jaspreet

former_member184578
Active Contributor
0 Kudos

Hi,

WDDOBEFOREACTION is the standard hook method, you cannt remove that. Instead in WDDOBEFOREACTION method, you can code based on the action. when you click button LOGIN, you can capture that button action and you can do coding accordingly. check the below code.

method WDDOBEFOREACTION .

   data lo_api_controller type ref to if_wd_view_controller.

   data lo_action         type ref to if_wd_action.

   lo_api_controller = wd_this->wd_get_api( ).

   lo_action = lo_api_controller->get_current_action( ).

   if lo_action is bound.

     case lo_action->name.

       when 'LOGIN'. " here LOGIN is the action name for button Login

        

*        Do code for Validation

        

        When 'REGISTER'. " here REGISTER is the action name for Register

         

*         Do Code for Registration

     endcase.

   endif.

endmethod.

Hope this helps u.,

Thanks & Regards,

Kiran