MVC Drop Down List Event Handler
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?
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"
<htmlb:gridLayoutCell columnIndex="2" rowIndex="2">
<htmlb:dropdownListBox id = "DDLB_SHIFT"
tooltip = "Shift"
table = "<%= v_shifts %>"
onSelect = "DDLB_SHIFTEvent"
selection = "<%= v_shiftsel %>">
nameOfKeyColumn = "SHIFT"
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.
data ?= cl_htmlb_manager=>get_data( request = runtime->server->request
name = 'dropdownListBox'
id = 'DDLB_PLANTEvent'
IF data IS NOT INITIAL.
c_plantsel = data->selection.