cancel
Showing results for 
Search instead for 
Did you mean: 

Getting default (first)-value of a BSP-dropdownlistbox without selecting it

Former Member
0 Kudos

On a MVC/BSP-page I have a dropdown-listbox and a button. I want to select a value from the listbox and press the button to create an object. That works fine.

But in some cases, I want to take the first (default) value of the listbox without selecting (that would be 2 Klicks)it. How can I get this value (without klicking) in the DO_EVENT_HANDLER ?

BSP:

<%

  • The following dropdown-Box only if 'BID'.

if drpdwn_flag = 1. %>

<% lr_fieldutil->set_field( iv_name = 'bid_type'

iv_data = ' ' ). %>

<td>

<htmlb:label for="<%=lr_fieldutil->get_id( )%>" id="bid_type_lb" text="Select a Template"/>

<htmlb:dropdownListBox id="<%=lr_fieldutil->get_id( )%>" nameOfKeyColumn="KEY" nameOfValueColumn="VALUE" table="<%=lt_template_types%>" selection="<%=controller->z_template_id%>" onSelect="templatetypesel" width="170px"/>

</td>

<% endif. %>

</tr>

<tr>

<td>

<htmlb:button id="CreateBIDINV"

onClick="CreateBIDINV"

text="<%= otr(development_projects_ui_bsp/create_bid) %>"

tooltip="Create bid invitation"/>

</td>

</tr>

-


DO_HANDLE_EVENT:

Dropdown-listbox:

IF htmlb_event_ex->event_name EQ cl_dpr_bsp_co=>sc_tn_dropdownlistbox.

lr_event_sel ?= htmlb_event_ex.

CASE htmlb_event_ex->event_server_name.

WHEN 'templatetypesel'.

me-><b>Z_TEMPLATE_ID</b> = lr_event_sel->selection. <= with value

mv_changed = cl_dpr_co=>sc_true.

…..

Button:

…..

ELSEIF htmlb_event_ex->event_server_name EQ 'CreateBIDINV'.

call Function 'Z_BID_CREATE_WITH_TEMPLATE'

destination RFCDESTINATION

exporting

uname = sy-uname

CPROJECT_ID = es_project_ext-project_id

CATEGORY_ID = es_project_ext-extended_attributes-category_id

TEMPLATE_OBJECT_ID = <b>z_template_id</b> <= without value

importing

OBJECT_ID = bidinv_no.

Thanks a lot for the help.

Accepted Solutions (1)

Accepted Solutions (1)

sreemsft
Contributor
0 Kudos

Hi Reinhard,

I did not get your problem properly?

1) Do you want to capture the value of the drop down list with out firing an event?

2) Your drop down will always has some default value if you do not pass any blank to it right??

If you are not appending any space to your table( lt_template_types ) which is in the dropdown list box, it will have some default value selected right??

->Do you want to fire an event without pressing the button?

In your code you already gave an event to your dropdown, so when ever you change the value DO_HANDLE_EVENT will trigger.

To get a default read the table <b>lt_template_types</b> index 1.

-> Do you want to read the value selected in the DROPDOWN.

You can get the value by reading the FORM_FIELDS in the DO_HANDLE_DATA.

Thanks,

Sreekanth

Former Member
0 Kudos

Hi Sreekanth,

<b>You can get the value by reading the FORM_FIELDS in the DO_HANDLE_DATA.</b>

That's the simplest solution, that works fine, thank you.

Regards

Reinhard

Answers (2)

Answers (2)

athavanraja
Active Contributor
0 Kudos

without onselect event of the dropdown, if the user presses the button you can use the following code to get the value in the drop down list box.

data: data type ref to cl_htmlb_dropdownlistbox.

clear data .

data ?= cl_htmlb_manager=>get_data( request = request

name = 'dropdownListBox'

id = 'DDLB1'

).

if data is not initial.

  • tab1sel = data->selection.

endif.

Regards

Raja

Former Member
0 Kudos

Hi Raja, you've unterstood my problem. I want just this:

<b>"without onselect event of the dropdown, if the user presses the button he wants to get the value in the drop down list box".</b>

The coding from you should work in the DO_HANDLE_EVENT, where the event of the buttonklick will be handled. I tried this, but no value came back from the "field = data->selection". Are there certain requests for that field who gets the data.

(I've tried as attribute of the handle class, or as local field). The DATA is not initial! But here's no value:(DATA->selection).

regards

Reinhard

athavanraja
Active Contributor
0 Kudos

i have tested this code and it works.

do you mean that you debugged it and in the debugging screen , you dont see field = data->selection getting filled (data->selection is empty?)

the only cause for that can be that you have a empty line in your itab passed to the dropdownlistbox.

here is the complete sample code i have used.

<u>controller</u>

DO_REQUEST method code.

 DATA: myview TYPE REF TO if_bsp_page.
  dispatch_input( ) .
  myview = create_view( view_name = 'view_test.htm' ).

  myview->set_attribute( name = 'name' value = sy-uname ).
  myview->set_attribute( name = 'tab1sel' value = tab1sel ).


  call_view( myview ).

DO_HANDLE_EVENT code


* tab1sel is instance/public type string declared in the class attribute
data: data type ref to cl_htmlb_dropdownlistbox.
clear data .
      data ?= cl_htmlb_manager=>get_data( request      = request
                                          name         = 'dropdownListBox'
                                          id           = 'DDLB1'
                                        ).
      if data is not initial.
        tab1sel = data->selection.
      endif.

<u>view_test.htm</u>

page attributes:

tab1 TYPE TIHTTPNVP

tab1sel TYPE STRING

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<htmlb:content design="design2003" >
  <htmlb:page title="Chained Selects" >
    <htmlb:form>
      <%
  select carrid carrname into table tab1 from scarr .
      %>
      <br>
      <%= tab1sel %>
      <htmlb:dropdownListBox id                = "DDLB1"
                             nameOfKeyColumn   = "NAME"
                             nameOfValueColumn = "VALUE"
                             table             = "<%= tab1 %>"
                             onSelect          = "DDLB1Event"
                             selection         = "<%= tab1sel %>"
                             width             = "150" />
<htmlb:button id = "BUT"
              text = "Click"
              onClick = "myonclick"/>
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

Regards

Raja

Former Member
0 Kudos

... and many thanks Raja, for your effort.

I've plumped for the form_fields-solution.

regards

Reinhard

athavanraja
Active Contributor
0 Kudos

glad you resolved it. you can mark the thread as answered now.

Raja

raja_thangamani
Active Contributor
0 Kudos

Hi,

<i>But in some cases, I want to take the first (default) value of the listbox without selecting (that would be 2 Klicks)it. How can I get this value (without klicking) in the DO_EVENT_HANDLER ?</i>

-->Thats possbile but i wanted to know what is that some cases, so that we can suggest your appropriate sloution.

Raja T

Former Member
0 Kudos

Hi, thanks for the quick answer. Some cases means: Everytime when the first (default) value of the Listbox is wanted, it should not be selected, but taken from the internal table of the values, or the shown (first) field on the BSP-Page from the dropdown-listbox.

Reinhard

sreemsft
Contributor
0 Kudos

Hi Reinhard,

Still you are not clear!!!

Do you want to display a blank value in the DROPDOWN for the first time when you run the application? and Do you want to select the internal table value by choosing the DROPDOWN button?

Thanks,

Sreekanth

Former Member
0 Kudos

ok, no blank value, its always a value there.(The dropdownbox comes only when values are available) No Button, thats still my problem: When the User wants to select the first (shown without clicking in the dropdowmlistbox) value, he don't want to click first the dropdown and then the button, but only the button and value should be selected in the DO_HANDLE_EVENTS. I want to get the value(s) from the internal table for the dropdown-listbox that is filled in the bsp-Page here in DO_HANDLE_EVENTS. ok?

Reinhard

sreemsft
Contributor
0 Kudos

Reinhard,

How will it goes to DO_HANDLE_EVENT when there is no event fired on the page.

For your clarification.

DO_HANDLE_EVENT and DO_HANDLE_DATA 

will fire only when there is anyevent occured on the page.

DO_INIT( ). " Fires only once in stateful mode.

DO_REQUEST( ). " Fire for each request

DISPATCH_INPUT( ). " Fires the next events like DO_HANDLE EVENT( ) and DO_HANDLE_DATA( ) in a proper way..

DO_HANDLE_EVENT and DATA will not fire if the method DISPATCH_INUT( )is not placed in the DO_REQUEST( ) method.

I have a doubt!!! What do you do with a default values selecting from the dropdown box with firing an event?

If you want you can read the table with index 1. so that it will gives a single value and you can use it if you want.

Thanks,

Sreekanth

raja_thangamani
Active Contributor
0 Kudos

The following code will trigger the event from Dropdown without clicking any Button..

      <htmlb:dropdownListBox id                = "myid"
                              nameOfKeyColumn   = "NAME"
                              nameOfValueColumn = "VALUE"
                              selection  = "<%= selected_value %>"
                              onSelect          = "myclick"
                              table             = "<%= itab %>" />

Here DO_HENDLE_EVENT will be triggered.

Hope this will help.

<i>* Reward each helpful answer.</i>

Raja T

Message was edited by:

Raja T

sreemsft
Contributor
0 Kudos

Hi Raja,

He was already using the similar code.

<htmlb:dropdownListBox id="<%=lr_fieldutil->get_id( )%>" nameOfKeyColumn="KEY" nameOfValueColumn="VALUE" table="<%=lt_template_types%>" selection="<%=controller->z_template_id%>" <b>onSelect="templatetypesel"</b> width="170px"/>

I am still not clear about his doubt

Reinhard: Please let us clear a doubt!! Do you want to fire an event with out clicking the button??

If yes. It will already firing the event as your are keeping the above code which is in <b>bold</b>.

Please reward helpful answers

Thanks,

Sreekanth

raja_thangamani
Active Contributor
0 Kudos

Hi Reinhard,

As sreekanth mentioned, we are not clear what is your problem. Could you please re-state your question. I would suggest after composing please go thro once what ever you are typed.

Raja T