cancel
Showing results for 
Search instead for 
Did you mean: 

DropdownListBox doesn't keep selected values

Former Member
0 Kudos

Greetings experts!

I am facing one problem respecting htmlb:dropdownlistbox.

In my application I have a few fields to introduce parameters and search some values. The display is like this:

|----

-


!/| (dropdown)

|----

-


!/| (dropdown)

Button

Table with results of the search

The problem I have is that both dropdowns are empty after pushing the button. ¿Is there a way to keep the selected values selected?

This is the code of one of the dropdowns:

<htmlb:dropdownListBox id = "SUBTIPO_LOG_DROP"

selection = "<%= disp_subtipo_log %>" >

<htmlb:listBoxItem key ="<%= 'BLAN'%>" value ="<%= ' '%>" />

<htmlb:listBoxItem key ="<%= 'CMAS'%>" value ="<%= 'Carga masiva'%>" />

<htmlb:listBoxItem key ="<%= 'AAUT'%>" value ="<%= 'Agrupación automática'%>" />

</htmlb:dropdownListBox>

I get the selected value using

DATA: drop_subtipo TYPE REF TO cl_htmlb_dropdownlistbox.

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

name = 'dropdownListBox'

id = 'SUBTIPO_LOG_DROP').

me->disp_subtipo_log = drop_subtipo->selection.

I have tried using combobox and using an inner table replacing the listBoxItems and got no results. I have search and didn't found anything that helps me.

Please, help me!!

Best regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I think the issue is simple.

Instead of assigning the value to the drop down like this:

me->disp_subtipo_log = drop_subtipo->selection.

get the the value to a variable(have this variable in page attributes):

l_variable = drop_subtipo->selection. and pass this in the layout like

<htmlb:dropdownListBox id = "SUBTIPO_LOG_DROP"

selection = "<%= l_variable %>" >

This will work.

Edited by: Gopal_Jothi on Sep 24, 2010 7:24 AM

Former Member
0 Kudos

Hello Gopal_Jothi

I don't understand how but it have solved my problem. I think that I have been doing the very same thing before, but I have declared two new variables and now it works!!!

Thank you very much!

Best regards.

Answers (2)

Answers (2)

former_member233090
Active Contributor
0 Kudos

Example


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

<htmlb:content id="content" design="classic+design2002+design2003"
 controlRendering="sap"   rtlAutoSwitch    = "true">
        <htmlb:dropdownListBox    id          = "mydropdownListBox1" >
        <htmlb:listBoxItem      key         = "key_vbak" value = "vbak" />
        <htmlb:listBoxItem      key         = "key_vbap"  value = "vbap"  />

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

this is in layout

and this is in event handling


 DATA: data1 TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.
data1 ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
                                      name    = 'dropdownlistbox'
                                      id      = 'mydropdownListBox1').
   selection1 = radioButtongroup->selection.
   case selection1.
   when 'activate'.
**   IF data1 IS NOT INITIAL.
  selection2 = data1->selection.
  case selection2 .
  when 'key_vbak'.
write ur code here .
 when 'key_vbap'.
  write ur code here .
  endcase.
**  ENDIF.

hope this example helps you out...

Cheers,

bhavana

Former Member
0 Kudos

Hello, Bhavana.

Thank you for the answer.

The BSP is not MVC, is a simple BSP.

disp_subtipo_log is defined in Page Attributes tab. When I presh the button, in the event handler OnInputProccessing I am retrieving the selected item and I am able to do the search, but the dropdownlistbow appears to be empty.

The display is:

<htmlb:content design="design2003" >

<htmlb:page title="<%= otr(ZSRM_02/TT_PRINCIPAL) %>" >

<htmlb:dropdownListBox id = "SUBTIPO_LOG_DROP"

selection = "<%= disp_subtipo_log %>" >

<htmlb:listBoxItem key ="<%= 'BLAN'%>" value ="<%= ' '%>" />

<htmlb:listBoxItem key ="<%= 'CMAS'%>" value ="<%= 'Carga masiva'%>" />

<htmlb:listBoxItem key ="<%= 'AAUT'%>" value ="<%= 'Agrupación automática'%>" />

</htmlb:dropdownListBox>

</htmlb:page>

</htmlb:content>

In event handler I do not change the content of disp_subtipo_log.

¿How can I make it keep the selected value? ¿Perhaps I have to set explicitly the selected value? How could I set a value directly?

Best regards.

former_member233090
Active Contributor
0 Kudos

Hi,

was my code not helpful to u.... have u gone through it,....pls check the code which i have sent,.. it is the similar thng which you need,

Let me know if u have any issues in that...

Cheers,

Bhavana

Former Member
0 Kudos

Hi, Bhavana!

I have tried your code and it doesn't keep the selected value. When you click on a radio button the dropdown shows the first element in it. In this case it shows vbak, even vbap is selected when I click the 'activate' radio button.

Thak you for the code, but the problem persists.

Cheers.

former_member233090
Active Contributor
0 Kudos

Hi,

Is the application with MVC or simple BSP Page, can u brief it more,

If its MVC then check it putting the break point, May be the varible which u have used is not set globally.

cheers,

Bhavana