Input - Suggestions - OSP
If you need to use an Open Search Provider (OSP) to supply possible values, you can do this with the Input control's suggest event, and build the suggestionItems dynamically according to the results of the Open Search call.
Z2UI5_CL_SMPC_APP_509
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_509- Source file
z2ui5_cl_smpc_app_509.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.Input- Demo kit sample
sap.m.sample.InputSuggestionsOpenSearch- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: input, sap.m, inputsuggestionsopensearch, verticallayout, label, item
Controls it builds
Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.
Libraries
Run it here
The sample running, in this page — the app on its own, with no editor over it.
Switch to Playground with this code
Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.
The ABAP
z2ui5_cl_smpc_app_509.clas.abap — 230 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords input sap.m inputsuggestionsopensearch verticallayout label item
" @summary If you need to use an Open Search Provider (OSP) to supply possible values, you can do this with the Input control's suggest event, and build the suggestionItems dynamically according to the results of the Open Search call.
CLASS z2ui5_cl_smpc_app_509 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES: BEGIN OF ty_s_product,
name TYPE string,
END OF ty_s_product.
TYPES ty_t_product TYPE STANDARD TABLE OF ty_s_product WITH EMPTY KEY.
DATA t_suggestions TYPE ty_t_product.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
METHODS products_all RETURNING VALUE(result) TYPE ty_t_product.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_509 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_navigated( ).
view_display( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->ele( n = `VerticalLayout` ns = `l`
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `width` v = `100%`
)->tag( `Label`
)->a( n = `text` v = `Product`
)->a( n = `labelFor` v = `productInput`
" onSuggest asks an OpenSearchProvider (a mock server) and replaces the
" suggestion items with what it answers - the same search runs in ABAP and
" fills the bound aggregation
)->ele( `Input`
)->a( n = `id` v = `productInput`
)->a( n = `placeholder` v = `Enter product`
)->a( n = `showSuggestion` v = `true`
)->a( n = `suggestionItems` v = client->_bind( t_suggestions )
)->a( n = `suggest` v = client->_event( val = `SUGGEST` arg = `${$parameters>/suggestValue}` )
)->ele( `suggestionItems`
)->tag( n = `Item` ns = `core`
)->a( n = `text` v = `{NAME}` ).
client->view_display( view->stringify( ) ).
" the original builds its suggestions imperatively (addSuggestionItem), which no
" size limit applies to; this port binds the aggregation, so the limit has to be
" raised - a one-character term matches over 100 of the 123 products
client->follow_up_action( val = client->cs_event-set_size_limit
t_arg = VALUE #( ( `100000` ) ( client->cs_view-main ) ) ).
ENDMETHOD.
METHOD on_event.
IF client->get_event( ) = `SUGGEST`.
DATA(term) = to_upper( client->get_event_arg( ) ).
CLEAR t_suggestions.
IF term IS NOT INITIAL.
LOOP AT products_all( ) INTO DATA(product).
IF to_upper( product-name ) CS term.
APPEND product TO t_suggestions.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD products_all.
" the product names the sample's mock search service answers with
result = VALUE #(
( name = `Notebook Basic 15` )
( name = `Notebook Basic 17` )
( name = `Notebook Basic 18` )
( name = `Notebook Basic 19` )
( name = `ITelO Vault` )
( name = `Notebook Professional 15` )
( name = `Notebook Professional 17` )
( name = `ITelO Vault Net` )
( name = `ITelO Vault SAT` )
( name = `Comfort Easy` )
( name = `Comfort Senior` )
( name = `Ergo Screen E-I` )
( name = `Ergo Screen E-II` )
( name = `Ergo Screen E-III` )
( name = `Flat Basic` )
( name = `Flat Future` )
( name = `Flat XL` )
( name = `Laser Professional Eco` )
( name = `Laser Basic` )
( name = `Laser Allround` )
( name = `Ultra Jet Super Color` )
( name = `Ultra Jet Mobile` )
( name = `Ultra Jet Super Highspeed` )
( name = `Multi Print` )
( name = `Multi Color` )
( name = `Cordless Mouse` )
( name = `Speed Mouse` )
( name = `Track Mouse` )
( name = `Ergonomic Keyboard` )
( name = `Internet Keyboard` )
( name = `Media Keyboard` )
( name = `Mousepad` )
( name = `Ergo Mousepad` )
( name = `Designer Mousepad` )
( name = `Universal card reader` )
( name = `Proctra X` )
( name = `Gladiator MX` )
( name = `Hurricane GX` )
( name = `Hurricane GX/LN` )
( name = `Photo Scan` )
( name = `Power Scan` )
( name = `Jet Scan Professional` )
( name = `Jet Scan Professional` )
( name = `Copymaster` )
( name = `Surround Sound` )
( name = `Blaster Extreme` )
( name = `Sound Booster` )
( name = `Lovely Sound 5.1 Wireless` )
( name = `Lovely Sound 5.1` )
( name = `Lovely Sound Stereo` )
( name = `Smart Office` )
( name = `Smart Design` )
( name = `Smart Network` )
( name = `Smart Multimedia` )
( name = `Smart Games` )
( name = `Smart Internet Antivirus` )
( name = `Smart Firewall` )
( name = `Smart Money` )
( name = `PC Lock` )
( name = `Notebook Lock` )
( name = `Web cam reality` )
( name = `Screen clean` )
( name = `Fabric bag professional` )
( name = `Wireless DSL Router` )
( name = `Wireless DSL Router / Repeater` )
( name = `Wireless DSL Router / Repeater and Print Server` )
( name = `USB Stick` )
( name = `Travel Adapter` )
( name = `Cordless Bluetooth Keyboard, english international` )
( name = `Flat XXL` )
( name = `Pocket Mouse` )
( name = `PC Power Station` )
( name = `Astro Laptop 1516` )
( name = `Astro Phone 6` )
( name = `Benda Laptop 1408` )
( name = `Bending Screen 21HD` )
( name = `Broad Screen 22HD` )
( name = `Cerdik Phone 7` )
( name = `Cepat Tablet 10.5` )
( name = `Cepat Tablet 8` )
( name = `Server Basic` )
( name = `Server Professional` )
( name = `Server Power Pro` )
( name = `Family PC Basic` )
( name = `Family PC Pro` )
( name = `Gaming Monster` )
( name = `Gaming Monster Pro` )
( name = `7" Widescreen Portable DVD Player w MP3` )
( name = `10" Portable DVD player` )
( name = `Portable DVD Player with 9" LCD Monitor` )
( name = `CD/DVD case: 264 sleeves` )
( name = `Audio/Video Cable Kit - 4m` )
( name = `Removable CD/DVD Laser Labels` )
( name = `Beam Breaker B-1` )
( name = `Beam Breaker B-2` )
( name = `Beam Breaker B-3` )
( name = `Play Movie` )
( name = `Record Movie` )
( name = `ITelo MusicStick` )
( name = `ITelo Jog-Mate` )
( name = `Power Pro Player 40` )
( name = `Power Pro Player 80` )
( name = `Flat Watch HD32` )
( name = `Flat Watch HD37` )
( name = `Flat Watch HD41` )
( name = `Copperberry` )
( name = `Silverberry` )
( name = `Goldberry` )
( name = `Platinberry` )
( name = `ITelO FlexTop I4000` )
( name = `ITelO FlexTop I6300c` )
( name = `ITelO FlexTop I9100` )
( name = `ITelO FlexTop I9800` )
( name = `Smartphone Leather Case` )
( name = `Smartphone Alpha` )
( name = `Mini Tablet` )
( name = `Camcorder View` )
( name = `Tablet Pouch` )
( name = `Tablet Pouch` )
( name = `e-Book Reader ReadMe` )
( name = `Smartphone Beta` )
( name = `Maxi Tablet` )
( name = `Flyer` ) ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- Input - Key and Value Tabular Suggestions — This sample illustrates how the Input works with key and value values, when the data is p…
- MultiInput tokenUpdate event example — MultiInput fires several tokenUpdate events depending on when the tokens were validated.
- Table - Outdated Data — You can use the 'showOverlay' property to indicate that the table data is no longer up to…
- Icon Tab Bar - Tabs drag and drop — This example shows how the tab filters can be reordered and nested with drag and drop. Wo…
- Input - Grouping of items — Items in the Input could be grouped by a property
- List - Header & Info Toolbar — The 'headerText' property is an easy but limited way of setting the list header. If you n…
- Input - Custom Value Help Icon — This example shows the usage of a custom value help icon instead of the default one.
- Select - Change Events — Demonstrates the use of 'change' and 'liveChange' events.
- MultiInput - Model update — This sample illustrates how the model bound to the MultiInput can be updated upon token c…
- Object Header Responsive II — This is a responsive Object Header with a Title, 2 Statuses/Attributes rendered below the…
- Flex Box - Size Adjustments — Automatic size adjustments can be achieved for Flex Items with the use of Flex Item Data…
- Input - Assisted — Assisted input is available via suggestions - shown as you type - and a value help dialog.
On this page