on 10-30-2014 5:18 PM
Hi there,
That's the first time I need to do a BSP. I have no much idea about MVC, but some .net developer from the company where I work tried to help me with the concepts ideas.
I have a problem now, and I'm trying to looking for the answer on Google and SDN but I found nothing yet...
How can I call another view? As I mentioned before, my collegues helped me a bit, and they told me first I need to go to controller, and after the controller call the view, is it correct?
METHOD do_handle_event.
DATA: o_ctrl TYPE REF TO cl_bsp_controller.
o_ctrl = create_controller( controller_name = 'acoes' ).
o_ctrl->set_attribute( name = me->c_obj_apo " apo
value = me->apo ).
me->call_controller( o_ctrl ).
ENDMETHOD.
When I'm debugging it's right, but my other view is never displayed...
Does anyone have a suggestion?
Hi,
There are several SDN links and other sites which has enormous tutorials for this!
Below is a simple appraoch for your issue:
Navigation to other views in MVC based BSP has to be done in DO_REQUEST of your controller.
DO_REQUEST is the round trip method called every time before page gets rendered. Hence DO_REQUEST is the method which decides the view that needs to be called.
Assume, you have 2 pages with events button1(view1) and button2(view2). When button clicked in view1, the corresponding event is being called, here you have to decide which view needs to be displayed next.
1. Create a global variable in your controller class, say target_view under Attributes tab
2. In your DO_HANLDE_EVENT, find the event being trigerred and set the destination page to the varibale target_view
DATA: lcl_event TYPE REF TO CL_HTMLB_EVENT_BUTTON. "date event
IF htmlb_event IS BOUND AND htmlb_event->name = 'button'.
lcl_event ?= htmlb_event.
if lcl_event->server_event = 'button1'.
target_view = 'view2.htm'.
ELSEIF lcl_event->server_event = 'button2'.
target_view = 'view1.htm'.
endif.
ENDIF.
3. Now, in DO_REQUEST create and call the destination view based on your global varibale target_view
DATA: lif_view TYPE REF TO if_bsp_page.
dispatch_input( ).
IF target_view EQ 'view1.htm' or target_view EQ space.
lif_view = create_view( view_name = 'view1.htm' ).
ELSEIF target_view = 'view2.htm'.
lif_view = create_view( view_name = 'view2.htm' ).
ENDIF.
call_view( lif_view ).
For further Reference to MVC in BSP, please refer Model View Controller Tutorial - Business Server Pages - SAP Library
Hope this will be helpful!
Regards,
Meganadhan S
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 | |
7 | |
6 | |
6 | |
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.