abap2UI5

Browser

Sets the browser tab title from the app, so a bookmarked or duplicated window says which app it holds.

Z2UI5_CL_SMP_APP_125

Learn Browser UI5 1.71

The facts

Repository
abap2UI5/samples
Class
Z2UI5_CL_SMP_APP_125
Source file
z2ui5_cl_smp_app_125.clas.abap
Category
Browser
Learning path
Reach outside the view
Minimum UI5
1.71 — the floor abap2UI5 holds its samples to
In the playground
runs in the browser, with no system and nothing installed
Documentation
abap2ui5.github.io/docs/cookbook/browser_interaction/title ↗

Keywords: document.title, tab, caption, headline, set_title

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_smp_app_125.clas.abap — 66 lines Read it on GitHub ↗
" @keywords document.title tab caption headline set_title
" @summary Sets the browser tab title from the app, so a bookmarked or duplicated window says which app it holds.
" @docs https://abap2ui5.github.io/docs/cookbook/browser_interaction/title
CLASS z2ui5_cl_smp_app_125 DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

    DATA title TYPE string VALUE `my title`.

  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_smp_app_125 IMPLEMENTATION.


  METHOD z2ui5_if_app~main.

    IF client->check_on_navigated( ).

      DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
          )->ele( n = `View` ns = `mvc`
              )->a( n = `displayBlock` v = `true`
              )->a( n = `height`       v = `100%`
              )->a( n = `xmlns`        v = `sap.m`
              )->a( n = `xmlns:mvc`    v = `sap.ui.core.mvc`
              )->a( n = `xmlns:core`   v = `sap.ui.core`
              )->a( n = `xmlns:form`   v = `sap.ui.layout.form` ).
      DATA(page) = view->ele( `Shell`
          )->ele( `Page`
              )->a( n = `title`          v = `abap2UI5 - Browser - Set the Tab Title`
              )->a( n = `showNavButton`  b = client->check_app_prev_stack( )
              )->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).

      page->tag( `MessageStrip`
          )->a( n = `text`     v = `Enter a title and press the button to run the set_title front-end action, which updates ` &&
                     `the browser tab title (document.title) without reloading the page.`
          )->a( n = `type`     v = `Information`
          )->a( n = `showIcon` b = abap_true
          )->a( n = `class`    v = `sapUiSmallMargin` ).

      page->ele( n = `SimpleForm` ns = `form`
          )->a( n = `title`    v = `Form Title`
          )->a( n = `editable` b = abap_true
          )->ele( n = `content` ns = `form`
              )->tag( `Label`
                  )->a( n = `text` v = `title`
              )->tag( `Input`
                  )->a( n = `value` v = client->_bind( title )
              )->tag( `Button`
                  )->a( n = `press` v = client->_event( `SET_TITLE` )
                  )->a( n = `text`  v = `Set Title` ).
      client->view_display( view->stringify( ) ).

    ELSEIF client->check_on_event( `SET_TITLE` ).

      client->follow_up_action(
          val   = z2ui5_if_client=>cs_event-set_title
          t_arg = VALUE #( ( title ) ) ).

    ENDIF.

  ENDMETHOD.
ENDCLASS.

More in Browser

Search every abap2UI5 sample · the full list on one page

On this page