cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

MVC design pattern for developing BSP Applications

Former Member
0 Likes
809

Hello all,

I have just started my exploration in the MVC design pattern of BSP applications.(Beginner)

First let me tell, what my need is : When I run an application, an initial page should be shown with an input field and a button. On clicking the button the <u>value typed in the input field of the first page must be displayed in a new page</u>.

I am trying to do this with MVC design pattern. I know how to do the same if both were to be diplayed on the same page ( A single page with two views ). But I don't know how to do it, <u>if the second view is to be shown on a new page.</u>

Could any of you give me a hint on this.

Thanks and regards.

Loveline.

View Entire Topic
Former Member
0 Likes

Hi Rainer,

Thanks for the immediate response. But I haven't meant my requirement.

This is the code written in the layout of my first view

<htmlb:content>

<htmlb:page title="First Page " >

<htmlb:form>

<htmlb:gridLayout columnSize = "2"

rowSize = "1"

cellSpacing = "10"

cellPadding = "10"

style = "TRANSPARENT" >

<htmlb:gridLayoutCell columnIndex = "1"

rowIndex = "1" >

<htmlb:inputField id = "IF1"

size = "10" />

</htmlb:gridLayoutCell>

<htmlb:gridLayoutCell columnIndex = "2"

rowIndex = "1" >

<htmlb:button id = "B1"

text = "Click Me"

onClick = "click" />

</htmlb:gridLayoutCell>

</htmlb:gridLayout>

</htmlb:form>

</htmlb:page>

</htmlb:content>

Now if I place the code <bsp:goto> as shown below

<%@page language="abap" %>

<%@extension name="htmlb" prefix="htmlb" %>

<%@extension name="bsp" prefix="bsp" %>

<htmlb:content>

<htmlb:page title="First Page " >

<htmlb:form>

<htmlb:gridLayout columnSize = "2"

rowSize = "1"

cellSpacing = "10"

cellPadding = "10"

style = "TRANSPARENT" >

<htmlb:gridLayoutCell columnIndex = "1"

rowIndex = "1" >

<htmlb:inputField id = "IF1"

size = "10" />

</htmlb:gridLayoutCell>

<htmlb:gridLayoutCell columnIndex = "2"

rowIndex = "1" >

<htmlb:button id = "B1"

text = "Click Me"

onClick = "click" />

<u><bsp:goto url = "Second.do" ></u>

<u></bsp:goto></u>

</htmlb:gridLayoutCell>

</htmlb:gridLayout>

</htmlb:form>

</htmlb:page>

</htmlb:content>

The first view is not being dislayed (nor the second view).

I don't think the <bsp:goto> will work out.

Once again thanks!

Best Regards,

Loveline.

maximilian_schaufler
Active Contributor
0 Likes

Hi Thomas,

maybe my suggestion might be too simple, but often these ways are the best ...

Did you try working with the "target"-attribute in the htmlb:form tag?

From what I understood from your posts that should satisfy your needs ...

Use this in the first view:

<htmlb:form target="_blank">

To call another controller, you could place the target controller there as well:

<htmlb:form target="_blank" action="secondController.do">

So, to sum up, small example:

View 1:

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>

<htmlb:content design="design2003">
  <htmlb:page title = " ">
    <htmlb:form target="_blank" action="test2.do">
      <htmlb:inputField   id            = "test_string"
                          value         = "XXXXXXX"/>
      <htmlb:button       text          = "Press Me"
                          onClick       = "EvtBtnPressme" />
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

Controller 2 - Method DO_REQUEST:

method do_request .

*** Data Defs ***
data: main_view type ref to if_bsp_page.

*** Event Handling
dispatch_input( ).

*** Call Main View
main_view = create_view( view_name = 'test2.htm' ).
main_view->set_attribute(     name = 'test_string'
                             value = me->test_string ).
call_view( main_view ).

endmethod.

Controller 2 - Method DO_HANDLE_DATA:

method do_handle_data .

*** Data Defs ***
  field-symbols: <field> type ihttpnvp.

* Test-String
  read table form_fields with table key
       name = 'test_string' assigning <field>.
  if <field> is assigned.
    me->test_string = <field>-value.
  else.
    clear me->test_string.
  endif.

endmethod.

View 2:

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>

<htmlb:content design="design2003">
  <htmlb:page title = " ">
    <htmlb:form>
      <htmlb:textView     text          = "<%=test_string%>"
                          design        = "EMPHASIZED" />
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

And don't forget to create a page attribute for the second view.

(test_string type string)

I hope I didn't forget anything, and that this was helpful to you.

Max

Former Member
0 Likes

Hello Maximilian,

your solution, or sample code might helps me also,

This is ur sample code for do_request method or controller 2

Method DO_REQUEST:

method do_request .

      • Data Defs ***

data: main_view type ref to if_bsp_page.

      • Event Handling

dispatch_input( ).

      • Call Main View

main_view = create_view( view_name = 'test2.htm' ).

main_view->set_attribute( name = 'test_string'

<b>value = me->test_string</b> ).

call_view( main_view ).

endmethod.

It would be very nice of you, if you pls let me know what is me in value = me->test_string

from where we got this me->, ??

PS: you have used ( me-> ) also in your do_handle_data method of controller 2, ??

Many thanks,

Haider

Message was edited by: Syed Haider

maximilian_schaufler
Active Contributor
0 Likes

The <b>me</b> always references to the object you are currently in.

So in this example, when <b>me->test_string</b> is used in the method DO_REQUEST of the controller, then this variable used is an attribute of the controller class object.

P.S.: If you have any further question that might not be directly related to the original problem in this thread, then please open another thread for your next question - this will help improve future search results in the forum.

Message was edited by: Maximilian Moder

Former Member
0 Likes

Hi Maximilian,

so me in ABAP is as this in java,

Many thanks, I will try to do so,

I am facing problem of sending this input feild parameter from view to model via controller,?

It would be nice if you add a model class besides these (view and controller), to move test_string in the model class, ?

It would be very nice of you !

Many thanks,

Haider

maximilian_schaufler
Active Contributor
0 Likes

I really suggest you open up another thread, as this one is already marked "answered".

In the new thread, please also specify if you want your model class just simple like an application class or if you want to use data binding as well.

Former Member
0 Likes

Hi Maximilian,

Thanks, for ur suggestions, but I have already started a thread. here, with name "parameter passing + MVC"

But I though if you write a code for model class also in the same thread, it would be complete example as you have given sample code of view and controller,

I just want to have a simple model class, which has a method which recives the user input, as a parameter, Actually I wana call the BAPI in model class,

Many thanks,

your help would be appriciated, as you like in this thread or my thread with entitle "parameter passing + MVC"

Haider