Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

values in htmlb:dropdownListBox

Hello experts,

as I could not find a solution to my problem in the web, may I ask you for help.

I have built a small MVC test application. My view contains a htmlb:dropdownListBox, a button to submit and an inputField to display the selection. My problem: the selected value of this box is not transfered into the model attribute and the box does not keep the selected value when I click the submit-button. My understanding was, that the model is bound to the view so that the selected value should be transferred after submit to the model-attribute automatically. May be this is wrong. Could you help me to complete my coding?

Here the details for you:

--- Controllerclass ----
method do_init.
  data: slistentry type ihttpnvp.
  me->model ?= create_model( class_name = 'zcl_test_ddfeld_mo'
                             model_id   = 'test_ddfeld_mo' ).
  clear slistentry.
  slistentry-value  = 'Entry 1'.
  slistentry-name = 'e1'.
  append slistentry to me->model->dd_values.
  slistentry-value  = 'Entry 2'.
  slistentry-name = 'e2'.
  append slistentry to me->model->dd_values.
  slistentry-value  = 'Entry 3'.
  slistentry-name = 'e3'.
  append slistentry to me->model->dd_values.
endmethod.

method do_request.
  data: view type ref to if_bsp_page.
  dispatch_input( ).
  view ?= create_view( view_name = 'default.htm' ).
  view->set_attribute( name = 'model' value = me->model ).
  call_view( view ).
endmethod.

method do_handle_event.
  if htmlb_event_ex is bound.
    case htmlb_event_ex->event_server_name.
      when 'onClick_btn1'.
* Here further code will be implemented later
      when others.
    endcase.   
  endif.
endmethod.

Attributes:
MODEL as Ref to my modelclass

--- Modelclass ----
Attributes:
SELECTED_VALUE type string.
DD_VALUES type TIHTTPNVP.    "Filled in Controller Do_init

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

<htmlb:content design="design2003">
  <htmlb:page title = "Startseite ">
    <htmlb:form>

      <htmlb:button       text          = "Submit"
                          onClick       = "onClick_btn1" />

      <htmlb:dropdownListBox  id                = "dd_list1"
                              nameOfKeyColumn   = "name"
                              nameOfValueColumn = "value"
                              table             = "//model/dd_values"
                              selection         = "//model/selected_value" />

      <htmlb:inputField   id            = "inf_selected"
                          value         = "//model/selected_value"
                          disabled      = "true" />

    </htmlb:form>
  </htmlb:page>
</htmlb:content>

Pageattributes:
MODEL as Ref to my modelclass

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question