on 03-04-2013 6:41 AM
Hi friends,
I m facing one problem.
there is one MAIN view having linktoaction. once i click on this link, it should open a popup window having LOGIN view.
After we enter the data and click on submit button in popup window, it should close it and navigate to INPUT view instead MAIN view.
here i m not able to naviagate to INPUT view .guide me
Thanks & regards,
Narasimha.
Hi Narasimha,
As per your requirement you have a view with a link to login
When the user clicks on it a popup comes to enter login credentials
On successful login he is navigated to second view.
On unsuccessful login he will get an error message and navigation will be stopped
To realize the above requirement you need to do the following:
Create 3 views and 2 windows
V_MAIN : Initial view with the link to popup the login view
V_CONTENT : view to be populated on successful login
V_LOGIN : View to enter login credentials
W_MAIN : Holding V_MAIN(default view) and V_CONTENT
W_LOGIN : Holding V_LOGIN
Define outbound plug TO_CONTENT in V_MAIN
Define inbound plug FROM_MAIN in V_CONTENT
Define navigation link between the plugs created above.
Create a context node LOGIN in the component controller.
Add the attributes USERID and PASSWORD of type String.
Define a method READ_LOGIN_DETAILS in the component controller.
Maintain two exporting parameters EV_USERID and EV_PASSWORD of type string.
Add the following code:
DATA lo_nd_login TYPE REF TO if_wd_context_node.
DATA lo_el_login TYPE REF TO if_wd_context_element.
DATA ls_login TYPE wd_this->element_login.
CLEAR: ev_userid,
ev_password.
* navigate from <CONTEXT> to <LOGIN> via lead selection
lo_nd_login = wd_context->get_child_node( name = wd_this->wdctx_login ).
IF lo_nd_login IS BOUND.
* get element via lead selection
lo_el_login = lo_nd_login->get_element( ).
IF lo_el_login IS BOUND.
* get all declared attributes
lo_el_login->get_static_attributes(
IMPORTING
static_attributes = ls_login ).
ev_userid = ls_login-userid.
ev_password = ls_login-password.
ENDIF.
ENDIF.
Drag and drop the Login context node from component controller context to view controller context in view V_LOGIN.
Use Create Container Form wizard to create input fields for user id and password from the LOGIN context node.
In the view V_MAIN
Create an UI element LinkToAction and maintain an action 'RAISE_LOGIN_POPUP' to the events property onAction.
Add the following code in the event handler ONACTIONRAISE_LOGIN_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.
DATA lr_view_controller TYPE REF TO if_wd_view_controller.
lr_view_controller = wd_this->wd_get_api( ).
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_LOGIN'
title = 'Enter Login Details'
* 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
).
CALL METHOD lo_window->subscribe_to_button_event
EXPORTING
button = if_wd_window=>co_button_ok
button_text = 'Login'
action_name = 'LOGIN'
tooltip = 'Login'
action_view = lr_view_controller.
lo_window->open( ).
Create an Action 'LOGIN' in view V_MAIN.
Add the following code in the event handler ONACTIONLOGIN
DATA: lv_userid TYPE string,
lv_password TYPE string,
lv_msgid TYPE string.
*** Read login credentials
wd_comp_controller->read_login_details(
IMPORTING
ev_password = lv_password " string
ev_userid = lv_userid " string
).
*** Check whether the login credentials are valid or not
*** if valid navigate to content page else raise error message
IF lv_userid = 'abc' AND lv_password = '123'.
wd_this->fire_to_content_plg(
).
ELSE.
* 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 = 'Enter valid login credentials'
RECEIVING
message_id = lv_msgid.
ENDIF.
Hope, this helps .
Regards,
Sayan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Define the inbound and outbound plugs for both the views.
best regards,
Amol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narasimha,
One possible way is create 2 windows namely WINA,WINB. and 2 views namely VIEWA VIEWB. embed VIEW A in WINA and VIEWB in WINB.
Suppose u want to open second WINB from WINA .the following code will work:
DATA: lr_view TYPE REF TO if_wd_view_controller,
lr_api_main TYPE REF TO if_wd_component,
lr_window_man TYPE REF TO if_wd_window_manager.
l_window2 type REF TO IF_WD_WINDOW.
lr_view = wd_this->wd_get_api( ). lr_api_main = wd_comp_controller->wd_get_api( ). lr_window_man = lr_api_main->get_window_manager( ). *Creating the Popup Window
CALL METHOD lr_window_man->create_window
EXPORTING modal = abap_true
window_name = 'WINB' title = 'Demo example'
close_button = abap_true
RECEIVING window = wd_comp_controller->l_window2. wd_comp_controller->l_window2->open( ).
regards,
Amol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Narasimha,
As far your requirement you have 3 views,
view1 : contains the link to popup the view2
view2 : contains the login fields
view3 : view to be shown after successful login.
You can proceed in the following way:
1. Create an action 'LOGIN' in view1.
2. Assign the action to the login button of view2.
In the event handler for linktoaction raise the view 2 as pop up with button type co_button_yes. Before raising view2 as pop up use this method to assign the LOGIN action to the popup view button YES.
CALL METHOD lo_window->subscribe_to_button_event
EXPORTING
button = if_wd_window=>co_button_yes
button_text = 'Login'
action_name = 'LOGIN'
TOOLTIP = 'Login'
action_view = lr_view_controller.
3. Navigate from view 1 to view 3 on for valid login credentials in method handler for the action created.
Hope it helps. Let me know if you need any further inputs.
Regards,
Sayan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you need to do it in the other way. On click on link to action in MAIN view Navigate to the Input view and in the WDDOINIT method of INPUT view create popup for LOGIN window.
Now you can validate the LOGIN and on success you can close the popup.
Hope this helps u.,
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.