on 11-18-2009 7:57 AM
Hi all ,
i have a abap web dynpro application where i am calling a popup window on a button click in MAIN window
the popup window is having standard buttons OK and Close by default.
also, i have an input field in the popup view which is of mandatory type , but on OK click i want to display error message if the input field is initial . and when the inputfield is not initial than display sucess message.
How can this be done since i had tried the popup windows closes when i press on OK button . I am able to display the error message .
Thanks !!
Ravi
tou will have to create an action your your OK button and put the code in there to display the error message.
To subscribe the button to an event use the following code.
* Popup
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.
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_POPUP'
message_display_mode = if_wd_window=>co_msg_display_mode_selected
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
).
DATA: l_api TYPE REF TO if_wd_view_controller.
l_api = wd_this->wd_get_api( ).
" Subscribe to button event
lo_window->subscribe_to_button_event(
button = if_wd_window=>co_button_ok
action_name = 'ON_OK' " create method with this name in the Methods tab
action_view = l_api
is_default_button = abap_true ).
lo_window->open( ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
we have already tried this senario ...but the problem is when we click on OK button in the Popup window the error message gets displayed on the MAIN window and the popup window gets closed .
I need the error message to be displayed on the popup window and the popup window should not disapper.
i have also set the parameters as CLOSE_IN_ANY_CASE = abap_false
Hope you got my point !
Regards
Ravi
hi ,
there is exactly the same requirement :
proceed as below :
For creating a pop up message u must have one more window which will open as a pop up.
Create one window say ( WIN2 ) and one view say (VIEW2). Now embed this view in window( WIN1 ).
Take one message area in the view.
Insert the following piececode
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.
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'
message_display_mode = if_wd_window=>co_msg_display_mode_selected
* close_button = abap_true
button_kind = if_wd_window=>co_buttons_none
message_type = if_wd_window=>co_msg_type_none
default_button = if_wd_window=>co_button_ok
).
lo_window->open( ).
* get message manager
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_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_MESSAGE
exporting
MESSAGE_TEXT = LS_RET_MESSAGE-MESSAGE
MESSAGE_TYPE = 2
SHOW_AS_POPUP = ABAP_TRUE
*view = 'VIEW2'*
receiving
MESSAGE_ID = L_MSG_ID.
Message will come only to the pop up view.
rgds,
amit
hi,
what is the code you have written in OK button.
I hope you are not closing the window there.
If you set CLOSE_IN_ANY_CASE = abap_false then window wont get closed untill you explicitly close it.
Please paste your code written in OK button.
And where have you created OK button Action in Main Window or Popwindow.
You have to create the subscibe to button event in the Popup window 's Wddoinit method.
DATA lo_view_controller TYPE REF TO if_wd_view_controller.
lo_view_controller = wd_this->wd_get_api( ).
DATA lo_wdw_controller TYPE REF TO if_wd_window_controller.
lo_wdw_controller = lo_view_controller->get_embedding_window_ctlr( ).
DATA lo_item_popup_window TYPE REF TO if_wd_window.
lo_item_popup_window = lo_wdw_controller->get_window( ).
lo_item_popup_window->subscribe_to_button_event(
button = if_wd_window=>co_button_ok
button_text = 'otr_text'
action_name = 'OK'
action_view = lo_view_controller
is_default_button = abap_true
).
Now create an Action OK in pop up window and do validation there only.
It would work.
Hi,
U have to write this code in the wddoinit of the view( Pop up View ).
DATA lo_view_controller TYPE REF TO if_wd_view_controller.
lo_view_controller = wd_this->wd_get_api( ).
DATA lo_wdw_controller TYPE REF TO if_wd_window_controller.
lo_wdw_controller = lo_view_controller->get_embedding_window_ctlr( ).
DATA lo_item_popup_window TYPE REF TO if_wd_window.
lo_item_popup_window = lo_wdw_controller->get_window( ).
lo_item_popup_window->subscribe_to_button_event(
button = if_wd_window=>co_button_ok
button_text = 'OK'
action_name = 'OK'
action_view = lo_view_controller
is_default_button = abap_true
).
Now create one action in the pop up view with the name Ok.
Check now it will not allow to close the window on click of OK button. You have to close it explicitly.
You do not have to use the subscribe_to_button_event method in the main view, use it in the pop up view only.
Thank You !!
It's working now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
When u are using create_window method then set the value for CLOSE_IN_ANY_CASE parameter as ABAP_FALSE.
CLOSE_IN_ANY_CASE = abap_false
Now u can check the value for input field and print the eror message. If all the conditions are fine then u can close the window by using exit plugs of window.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi ,
in the onActionOk ,
1 read the context attribute which is binded to mandatory field and strore value in a variable
2 if the value is INITIAL , display error message , else successful message
DATA lo_window TYPE REF TO if_wd_window.
//for ur OnActionEvent
lo_window->subscribe_to_button_event(
button = if_wd_window=>co_button_ok
action_name = 'ONACTIONOK' // action name for OK button
action_view = l_api
is_default_button = abap_true ).
// *read the context attribute USERNAME under context node cn_all*
DATA lo_nd_cn_all TYPE REF TO if_wd_context_node.
DATA lo_el_cn_all TYPE REF TO if_wd_context_element.
DATA ls_cn_all TYPE wd_this->element_cn_all.
DATA lv_username LIKE ls_cn_all-username.
DATA lv_password LIKE ls_cn_all-password.
* navigate from <CONTEXT> to <CN_ALL> via lead selection
lo_nd_cn_all = wd_context->get_child_node(
name = wd_this->wdctx_cn_all ).
* get element via lead selection
lo_el_cn_all = lo_nd_cn_all->get_element( ).
* get single attribute
lo_el_cn_all->get_attribute(
EXPORTING
name = `USERNAME`
value = lv_username) .
// if lv_username is initial , display error message
IF lv_username is INITIAL.
* get message manager
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_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_error_message
EXPORTING
message_text = 'Error_Text' " Give your error text here.
ELSE.
// ur successful message using report_success_message method
ENDIF.
regards,
amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
what is code you have written to open pop up window ?
Try this one :
lr_popup = lr_window_manager->create_window(
MODAL = ABAP_TRUE
window_name = 'WND_POPUP' "Name of the window created
TITLE = 'Please enter all information'
CLOSE_BUTTON = ABAP_TRUE
BUTTON_KIND = if_wd_window=>CO_BUTTONS_YESNO
MESSAGE_TYPE = if_wd_window=>co_msg_type_error
CLOSE_IN_ANY_CASE = ABAP_FALSE
*MESSAGE_DISPLAY_MODE = MESSAGE_DISPLAY_MODE
).
close in any case - set it false.
Now it would work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.