Introduction
This document helps how to close web dynpro application browser window automatically after specified event/time.
Here I will explain a simple Scenario: After displaying success message the browser has to close automatically in 5 seconds.
Enter Description and click on ok.
Save and Activate the component.
Go to the Outbound Plugs tab of the window and create an EXIT plug with the parameter CLOSE_WINDOW of type WDY_BOOLEAN.
Go to the Context tab of Main View and create and create attributes : EMPID of type STRING and ENABLE of type WDY_BOOLEAN.
Right click on the Context and click on create attribute.
Create attribute EMPID of type STRING.
Similarly create an attribute ENABLE of type WDY_BOOLEAN.
Now Go to Layout tab:
Right click on ROOTUIELEMENTCONTAINER and click on Insert Element
Enter ID and select UI 'Label'.
Similarly create Input filed EMPID and bind the value to EMPID attribute.
Now create a button UI element.
Enter button Text and click on create button to create an Action for button.
Enter Action name, description and click on OK.
Now create a message area UI element to display messages.
Create a Timed Trigger UI element.
Bind the enable property of the timed trigger UI to the attribute ENABLE.
Set the delay time of timed trigger UI element.
Create an Action for timed trigger UI.
Now go to Properties tab and click on create button to create controller usage.
Select the controller by double clicking on it. We have to add the controller to make EXIT plug method of window in View Controller.
Now go to Methods tab of MAIN view and write the below code ONACTIONREGISTER method.
ONACTIONREGISTER |
---|
METHOD onactionregister . DATA lo_el_context TYPE REF TO if_wd_context_element. DATA ls_context TYPE wd_this->element_context. DATA lv_empid TYPE wd_this->element_context-empid. DATA lo_api_controller TYPE REF TO if_wd_controller. DATA lo_message_manager TYPE REF TO if_wd_message_manager. * get element via lead selection lo_el_context = wd_context->get_element( ). * get single attribute lo_el_context->get_attribute( EXPORTING name = `EMPID` IMPORTING value = lv_empid ). * Register the employee for event * CALL FUNCTION 'ZEMP_REGISTER' * EXPORTING * emp_id = lv_empid. IF sy-subrc = 0. * get message manager lo_api_controller ?= wd_this->wd_get_api( ). CALL METHOD lo_api_controller->get_message_manager RECEIVING message_manager = lo_message_manager. * report message CALL METHOD lo_message_manager->report_success EXPORTING message_text = 'Employee Registered Successfully!'. * Enable Self destruction lo_el_context->set_attribute( name = `ENABLE` value = abap_true ). ENDIF. ENDMETHOD. |
And Enter the below code in ONACTIONCLOSE_BROWSER method
ONACTIONCLOSE_BROWSER |
---|
METHOD onactionclose_browser . DATA lo_zwd_auto_close_demo TYPE REF TO ig_zwd_auto_close_demo . lo_zwd_auto_close_demo = wd_this->get_zwd_auto_close_demo_ctr( ). * Exit Application and Close Browser lo_zwd_auto_close_demo->fire_exit_plg( close_window = abap_true ). ENDMETHOD. |
Save and Activate the Web Dynpro Component. Create the Web Dynpro Application and Save it.
Enter description and save it.
Now Right click on Web Dynpro Application and click on Test.
The application will open in the browser. Enter the employee ID and click on Register button.
Now we will get success message upon successful registration of the employee.
After displaying the message the browser will close automatically after 5 seconds (delay time of timed trigger).
In chrome and IE7 the browser window will close automatically. In higher versions of IE the browser will prompt to confirm closing of the browser.
Conclusion
Here I demonstrated a simple Web Dynpro Application. We can use this according to our Requirements.
User | Count |
---|---|
12 | |
12 | |
5 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |