Browser
Navigates the browser to a same-domain URL with the location_reload front-end action, with a scratch input beside it to show what the reload takes with it.
- Class
z2ui5_cl_smp_app_492- Repository
- abap2UI5/samples
- UI5 libraries
- sap.m, sap.ui.core, sap.ui.layout
- Lowest UI5 release
- 1.71
- In the browser
- Runs in the playground
- Controls it builds
- sap.m.Button, sap.m.Input, sap.m.Label, sap.m.MessageStrip, sap.m.Page, sap.m.Shell, sap.ui.core.mvc.View, sap.ui.layout.form.SimpleForm
- Documentation
- cookbook/browser_interaction/url_handling ↗
The class
" @keywords reload refresh restart location_reload url
" @summary Navigates the browser to a same-domain URL with the location_reload front-end action, with a scratch input beside it to show what the reload takes with it.
" @docs https://abap2ui5.github.io/docs/cookbook/browser_interaction/url_handling
CLASS z2ui5_cl_smp_app_492 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA url TYPE string.
DATA scratch TYPE string.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_492 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
IF client->check_on_navigated( ).
DATA(s_config) = client->get( )-s_config.
url = |{ s_config-pathname }{ s_config-search }|.
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:form` v = `sap.ui.layout.form` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Browser - Reload the Page`
)->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 = `The location_reload front-end action navigates the browser to a same-domain URL. The url field is ` &&
`prefilled with this page's own address, so the button reloads the app from scratch - type something ` &&
`into the scratch field first and watch it get lost. Cross-origin URLs are blocked by the framework.`
)->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 = `Reload`
)->a( n = `editable` b = abap_true
)->ele( n = `content` ns = `form`
)->tag( `Label`
)->a( n = `text` v = `scratch input`
)->tag( `Input`
)->a( n = `placeholder` v = `type something - it is lost after the reload`
)->a( n = `value` v = client->_bind( scratch )
)->tag( `Label`
)->a( n = `text` v = `url`
)->tag( `Input`
)->a( n = `value` v = client->_bind( url )
)->tag( `Button`
)->a( n = `press` v = client->_event( `RELOAD` )
)->a( n = `text` v = `Reload Page` ).
client->view_display( view->stringify( ) ).
ELSEIF client->check_on_event( `RELOAD` ).
client->follow_up_action(
val = z2ui5_if_client=>cs_event-location_reload
t_arg = VALUE #( ( url ) ) ).
ENDIF.
ENDMETHOD.
ENDCLASS.