cancel
Showing results for 
Search instead for 
Did you mean: 

Data binding with tableview: no data returned...

Former Member
0 Kudos

Hi,

I looked at the example BSP_MODEL and now I am trying to build a simple test application with a tableview.

I can easily display data from my model in the tableview, but I can't get the modified data back to my model.

I have implemented the method DO_HANDLE_DATA in the table's controller with the following code:<i>

CALL METHOD super->do_handle_data

EXPORTING

form_fields = form_fields

global_messages = global_messages.</i>

The DO_INIT method is like this:

<i>m_model ?= create_model( model_id = 'm'

class_name = 'ZNP5' ).

if m_model is bound.

m_model->init( ). "a simple select on SFLIGHT

endif.</i>

Obviously I missed something, any idea?

Thanks for your help.

Nicolas

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Are you working stateless?

Former Member
0 Kudos

Hi Martin,

Yes I am working stateless...

Former Member
0 Kudos

OK, the example BSP_MODEL is stateful. Switch your application to statefull.

When you debug your app you'll see that in stateless-mode the do_init is called for each request - and that's the problem (I think).

Former Member
0 Kudos

My company's policy is to develop in stateless mode, I think I will use server side cookies to retain the data...

Former Member
0 Kudos

Hi Nicolas,

It is not advicable to use Server side cookies to store huge amount of data. Actually you have an option 'Stateful from now on' in BSP. This option is neither totally stateful or stateless. Whenever there is data exchange it is useful to set this property of the main page or controller from which the program starts.

Unless it is required,server side cookies should be used to store huge data.

Regards,

Vara

Former Member
0 Kudos

Hi Vara,

Thanks for your answer, I will explore this feature...

Regards,

Nicolas

Former Member
0 Kudos

Hi Nicolas,

Is your table defined as an attribute in your m_model class? Can you post your HTMLB tableview statement? And your select statement? You probably have a typo that needs another set of eyes to find. Happens to me all the time

Cheers,

Rich

Former Member
0 Kudos

Hi Richard,

Here are more details on my test application:

  • Model:

- Class Name: ZNP5, superclass: CL_BSP_MODEL

- Attributes: FLIGHTS, Public, TYPE FLIGHTTAB

- Method INIT, Public:

SELECT * FROM sflight INTO TABLE flights.

The BSP Applications consists of a main controller (main.do) and a subcontroller (table.do) calling views main.htm and table.htm.

  • MAIN.DO:

- DO_INIT method

DATA: subc1 TYPE REF TO cl_bsp_controller2.

subc1 ?= create_controller( controller_name = 'table.do'

controller_id = 'subc1' ).

- DO_REQUEST method

DATA: view TYPE REF TO if_bsp_page.

dispatch_input( ).

view ?= create_view( view_name = 'main.htm' ).

call_view( view ).

  • TABLE .DO

- Attributes: M_MODEL, Private, Type Ref To ZNP5

- DO_INIT method

m_model ?= create_model( model_id = 'm'

class_name = 'ZNP5' ).

if m_model is bound.

m_model->init( ).

Endif.

- DO_REQUEST method

DATA: view TYPE REF TO if_bsp_page.

view ?= create_view( view_name = 'table.htm' ).

view->set_attribute( name = 'model' value = m_model ).

call_view( view ).

- DO_HANDLE_DATA method

CALL METHOD super->do_handle_data

EXPORTING

form_fields = form_fields

global_messages = global_messages.

  • main.htm

<%@page language="abap" %>

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

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

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

<htmlb:content design="design2003" >

<htmlb:page title=" " >

<htmlb:form>

<bsp:call comp_id="subc1" />

</htmlb:form>

</htmlb:page>

</htmlb:content>

  • table.htm

Attributes: model Type ref to ZNP5

SelectedRow type string

<%@page language="abap" %>

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

<htmlb:tableView id = "tvX"

headerText = "Connections"

width = "100"

headerVisible = "true"

design = "alternating"

visibleRowCount = "8"

fillUpEmptyRows = "true"

showNoMatchText = "true"

filter = "server"

sort = "server"

onHeaderClick = "MyEventHeaderClick"

onRowSelection = "MyEventRowSelection"

selectionMode = "LINEEDIT"

selectedRowIndex = "<%= selectedRow %>"

table = "//model/flights"

tabIndexCell = "true" />

I've just discovered that the data is actually transfered to the model but it's not retained: When I edit the 1st line of the table, the modified values are transfered to the model, but if I edit the 2nd line, I loose the previous changes... How to solve this?

Regards,

Nicolas

Former Member
0 Kudos

Hi,

I've just noticed that the example BSP_MODEL is flagged STATEFUL...

I don't want to use stateful mode, what's the best way to store my table data? cookies ?

Regards,

Nicolas