on 01-03-2009 9:27 PM
Hi ,
I need to display a pop-up to the user in a WDA application if the session is inactive for 2 mins. Please explain how to do the same.
Thanks in anticpation.
Regards
Nidhi Jain
Nidhi,
I am not sure this works or not but give it a try.
1.Insert a TimedTrigger UI element.
2.set the dealy as 120(2 minutes)
3.Associate an event to its onAction property and write the below code
cl_web_dynpro=>is_active -
to check application is active or not.
if it returns false create a popup (check sdn on creating a popup)
Thanks
Bala Duvvuri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I built such a timeout as a reusable component before. Everytime there is a post back to the server, the timer gets rerendered with the delay value if it is data bound. That way any server event cause the timeout to reset.
In the WDDOINIT of the component controller, I calculate the timeout by reading the SICF settings:
data: name type pfeparname.
data: value type pfepvalue.
data: l_timeout type icftime.
data: timeout type int4,
trigger_timeout type int4.
clear: timeout, trigger_timeout.
****Get the App Server Timeout
name = 'rdisp/plugin_auto_logout'.
call 'C_SAPGPARAM' id 'NAME' field name
id 'VALUE' field value.
****Is there a specific Timeout set
if wdr_task=>server is bound.
if wdr_task=>server->session_timeout is initial.
timeout = value.
else.
****We got a specific timeout - now convert it to a number of seconds.
data: minutes type i.
l_timeout = wdr_task=>server->session_timeout.
minutes = l_timeout+0(2) * 60.
minutes = minutes + l_timeout+2(2).
timeout = ( minutes * 60 ) + l_timeout+4(2).
****If a specified timeout is larger than the default, it is ignored.
****Use the default instead.
if timeout > value.
timeout = value.
endif.
endif.
else.
timeout = value.
endif.
data lo_nd_configuration type ref to if_wd_context_node.
data lo_el_configuration type ref to if_wd_context_element.
data ls_configuration type wd_this->element_configuration.
lo_nd_configuration = wd_context->get_child_node( name = wd_this->wdctx_configuration ).
lo_el_configuration = lo_nd_configuration->get_element( ).
* get all declared attributes
lo_el_configuration->get_static_attributes(
importing
static_attributes = ls_configuration ).
data ls_timeout_info type wd_this->element_timeout_info.
if timeout > ls_configuration-msg_delay_secs.
trigger_timeout = timeout - ls_configuration-msg_delay_secs .
ls_timeout_info-final_logoff_timer = ls_configuration-msg_delay_secs.
else.
trigger_timeout = timeout - 60.
ls_timeout_info-final_logoff_timer = 60.
endif.
data lo_nd_timeout_info type ref to if_wd_context_node.
data lo_el_timeout_info type ref to if_wd_context_element.
lo_nd_timeout_info = wd_context->get_child_node( name = wd_this->wdctx_timeout_info ).
lo_el_timeout_info = lo_nd_timeout_info->get_element( ).
ls_timeout_info-session_timeout = timeout.
ls_timeout_info-trigger_timeout = trigger_timeout.
* set all declared attributes
lo_el_timeout_info->set_static_attributes(
static_attributes = ls_timeout_info ).
I have view with just timedTrigger. The delay is bound to TRIGGER_TIMEOUT attribute. I have an onAction called SHOWTIMEOUTPROMPT.
In the SHOWTIMEOUTPROMPT, I trigger a popup view:
method onactionshowtimeoutprompt .
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 lv_text_t01 type string.
lv_text_t01 =
wd_assist->if_wd_component_assistance~get_text( 'T01' ).
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 = 'W_PROMPT'
title = lv_text_t01
* close_in_any_case = abap_true
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
).
lo_window->open( ).
endmethod.
In the popup view, I give the user the opportunity to continue their session or they will be logged out. So I have another timer in the popup that will trigger a navigation plug once it counts down. If the user closes the dialog, the timer gets reset because it triggers a server event. Otherwise if there is no activity the final timer gets triggered.
Here is the WDDOINIT of the Promt View:
method wddoinit .
data lo_nd_timeout_info type ref to if_wd_context_node.
data lo_el_timeout_info type ref to if_wd_context_element.
data ls_timeout_info type wd_this->element_timeout_info.
lo_nd_timeout_info = wd_context->get_child_node( name = wd_this->wdctx_timeout_info ).
lo_el_timeout_info = lo_nd_timeout_info->get_element( ).
* get all declared attributes
lo_el_timeout_info->get_static_attributes(
importing
static_attributes = ls_timeout_info ).
data lo_el_context type ref to if_wd_context_element.
data ls_context type wd_this->element_context.
data lv_timeout_message type wd_this->element_context-timeout_message.
lo_el_context = wd_context->get_element( ).
data: s_minutes type string.
s_minutes = ls_timeout_info-final_logoff_timer / 60.
if s_minutes > 1.
data lv_text_q02 type string.
lv_text_q02 =
wd_assist->if_wd_component_assistance~get_text( 'Q02' ).
data lv_text_q03 type string.
lv_text_q03 =
wd_assist->if_wd_component_assistance~get_text( 'Q03' ).
concatenate lv_text_q02
s_minutes
lv_text_q03
into lv_timeout_message separated by space.
else.
data lv_text_q01 type string.
lv_text_q01 =
wd_assist->if_wd_component_assistance~get_text( 'Q01' ).
move lv_text_q01 to lv_timeout_message.
endif.
* set single attribute
lo_el_context->set_attribute(
name = `TIMEOUT_MESSAGE`
value = lv_timeout_message ).
endmethod.
And here is the event handler for the final timer:
method onactionlogoff .
data lo_nd_configuration type ref to if_wd_context_node.
data lo_el_configuration type ref to if_wd_context_element.
data ls_configuration type wd_this->element_configuration.
data lv_exit_url type wd_this->element_configuration-exit_url.
lo_nd_configuration = wd_context->get_child_node( name = wd_this->wdctx_configuration ).
lo_el_configuration = lo_nd_configuration->get_element( ).
* get single attribute
lo_el_configuration->get_attribute(
exporting
name = `EXIT_URL`
importing
value = lv_exit_url ).
data lo_componentcontroller type ref to ig_componentcontroller .
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->fire_logoff_evt( ).
data lo_w_main type ref to ig_w_main .
lo_w_main = wd_this->get_w_main_ctr( ).
lo_w_main->fire_exitapp_plg(
url = lv_exit_url ).
endmethod.
This is a reusable component, so it is actually firing an event in the hosting component. The hosting component can then decide how to handle the event - usually by trigging a navigation plug to itself.
Check this one for timetrigger ui element.
http://scn.sap.com/community/web-dynpro-abap/blog/2012/04/06/timer-in-webdynpro-abap
Hi Tom,
Thanks for the sharing wonderful help document and saves lot of time. I have one question though,, what is the context node and elements have you defined and what are the properties do we need to set.
As per the code I think the node structure looks like , please correct me if I am wrong.
First Node:
Node : --Configuration
--timeout_message
Second node:
--timeout_info
is that correct?
OR
In the mean time is there any thing changed like SAP might have already delivered this component as generic util comp but not sure.
Thanks
Krish
Hi Thomas,
I'm working on a webdynpro application using suspend/resume plugs to navigate to third party Payment Gateway(PG), if user does not complete payment tarnsaction and return to SAP application before set time I'm having session timeout error. Is there any way to avoid timeout in this application scenario. Any help is much appreciated. Thanks
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.