|
| 1 | +--- |
| 2 | +outline: [2, 4] |
| 3 | +--- |
| 4 | +# Frontend Info |
| 5 | + |
| 6 | +abap2UI5 offers a custom control for reading all frontend information from the user's device — UI5 version and theme, browser, operating system, system type, screen dimensions, and device class (phone, tablet, desktop). This is handy whenever your ABAP logic needs to adapt to the runtime environment. |
| 7 | + |
| 8 | +The control collects the values on the frontend and returns them via two-way binding. Once the `finished` event fires, all bound attributes are filled and available to ABAP. See also `Z2UI5_CL_DEMO_APP_122`. |
| 9 | + |
| 10 | +```abap |
| 11 | +CLASS z2ui5_cl_sample_frontend_info DEFINITION PUBLIC. |
| 12 | +
|
| 13 | + PUBLIC SECTION. |
| 14 | + INTERFACES z2ui5_if_app. |
| 15 | +
|
| 16 | + DATA ui5_version TYPE string. |
| 17 | + DATA ui5_theme TYPE string. |
| 18 | + DATA ui5_gav TYPE string. |
| 19 | + DATA device_systemtype TYPE string. |
| 20 | + DATA device_os TYPE string. |
| 21 | + DATA device_browser TYPE string. |
| 22 | + DATA device_phone TYPE abap_bool. |
| 23 | + DATA device_desktop TYPE abap_bool. |
| 24 | + DATA device_tablet TYPE abap_bool. |
| 25 | + DATA device_combi TYPE abap_bool. |
| 26 | + DATA device_height TYPE string. |
| 27 | + DATA device_width TYPE string. |
| 28 | +
|
| 29 | +ENDCLASS. |
| 30 | +
|
| 31 | +CLASS z2ui5_cl_sample_frontend_info IMPLEMENTATION. |
| 32 | +
|
| 33 | + METHOD z2ui5_if_app~main. |
| 34 | +
|
| 35 | + DATA(view) = z2ui5_cl_xml_view=>factory( ). |
| 36 | + client->view_display( view->shell( |
| 37 | + )->page( )->_z2ui5( |
| 38 | + )->info_frontend( |
| 39 | + finished = client->_event( `POST` ) |
| 40 | + device_browser = client->_bind_edit( device_browser ) |
| 41 | + device_os = client->_bind_edit( device_os ) |
| 42 | + device_systemtype = client->_bind_edit( device_systemtype ) |
| 43 | + ui5_gav = client->_bind_edit( ui5_gav ) |
| 44 | + ui5_theme = client->_bind_edit( ui5_theme ) |
| 45 | + ui5_version = client->_bind_edit( ui5_version ) |
| 46 | + device_phone = client->_bind_edit( device_phone ) |
| 47 | + device_desktop = client->_bind_edit( device_desktop ) |
| 48 | + device_tablet = client->_bind_edit( device_tablet ) |
| 49 | + device_combi = client->_bind_edit( device_combi ) |
| 50 | + device_height = client->_bind_edit( device_height ) |
| 51 | + device_width = client->_bind_edit( device_width ) |
| 52 | + )->stringify( ) ). |
| 53 | +
|
| 54 | + CASE client->get( )-event. |
| 55 | + WHEN `POST`. |
| 56 | + "process frontend info here... |
| 57 | + ENDCASE. |
| 58 | +
|
| 59 | + ENDMETHOD. |
| 60 | +ENDCLASS. |
| 61 | +``` |
| 62 | + |
| 63 | +::: tip **Bind Directly in the View** |
| 64 | +If you only need device information in the view (not in ABAP logic), bind to the built-in UI5 device model via `{device>/...}` instead — no backend roundtrip required. See [Device Model](../model/device.md). |
| 65 | +::: |
0 commit comments