Skip to Content

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

MVC Drop Down List Event Handler

Hello,

I am trying to create a bsp page using MVC design pattern. I have 3 drop down list fields which are dependent on each other. Example: When you select a value in list 1, drop down list 2 becomes enabled for selection with values based on list 1. At this point of time list 3 should be disabled. Once you select value from 2, list 3 becomes enabled with values based on list 2 selection.

I have seen a webblog on this topic from Raja but it was designed for bsp page flow design. Could you please guide how do I achieve this in MVC?

Please help.

This is what I did:

I have 1 controller and 1 view.

In my view:

=========================================================

<htmlb:gridLayoutCell columnIndex="2" rowIndex="1">

<htmlb:dropdownListBox id = "DDLB_PLANT"

tooltip = "Plant"

table = "<%= v_plants %>"

onSelect = "DDLB_PLANTEvent"

selection = "<%= v_plantsel %>">

nameOfKeyColumn = "WERKS"

nameOfValueColumn= "DESC_TEXT">

</htmlb:dropdownListBox>

</htmlb:gridLayoutCell>

<htmlb:gridLayoutCell columnIndex="2" rowIndex="2">

<htmlb:dropdownListBox id = "DDLB_SHIFT"

tooltip = "Shift"

table = "<%= v_shifts %>"

onSelect = "DDLB_SHIFTEvent"

selection = "<%= v_shiftsel %>">

nameOfKeyColumn = "SHIFT"

nameOfValueColumn= "SDESC">

</htmlb:dropdownListBox>

</htmlb:gridLayoutCell>

where v_plants and v_shifts are page attributes (table) that is being populated in DO_REQUEST method of controller. v_plantsel and v_shiftsel are type string (page attribute).

In DO_HANDLE_EVENT (controller)

DATA: event_id TYPE REF TO if_htmlb_data,

ddlb_event TYPE REF TO cl_htmlb_event_selection,

data TYPE REF TO cl_htmlb_dropdownlistbox.

event_id = cl_htmlb_manager=>get_event( request ).

IF event_id IS NOT INITIAL.

ddlb_event ?= event_id.

IF ddlb_event->id EQ 'DDLB_PLANTEvent'.

c_plantsel = ddlb_event->selection.

ELSEIF ddlb_event->id EQ 'DDLB_SHIFTEvent'.

c_shiftsel = ddlb_event->selection.

CLEAR data.

data ?= cl_htmlb_manager=>get_data( request = runtime->server->request

name = 'dropdownListBox'

id = 'DDLB_PLANTEvent'

).

IF data IS NOT INITIAL.

c_plantsel = data->selection.

ENDIF.

ENDIF.

ENDIF.

=========================================================

Thanks,

Partho

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