Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navigation with app state #468

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/z2ui5_cl_demo_app_320.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ CLASS z2ui5_cl_demo_app_320 DEFINITION
CREATE PUBLIC.

PUBLIC SECTION.
INTERFACES if_serializable_object.
INTERFACES z2ui5_if_app.

DATA check_initialized TYPE abap_bool.
Expand Down
79 changes: 79 additions & 0 deletions src/z2ui5_cl_demo_app_321.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
CLASS z2ui5_cl_demo_app_321 DEFINITION
PUBLIC FINAL
CREATE PUBLIC.

PUBLIC SECTION.
INTERFACES z2ui5_if_app.

DATA mv_product TYPE string.
DATA mv_quantity TYPE string.
DATA mv_search TYPE string.

DATA mt_search TYPE z2ui5_cl_util=>ty_t_name_value.
PROTECTED SECTION.


DATA client TYPE REF TO z2ui5_if_client.
METHODS state_handling
RETURNING
VALUE(result) TYPE abap_bool.

ENDCLASS.


CLASS z2ui5_cl_demo_app_321 IMPLEMENTATION.

METHOD z2ui5_if_app~main.
me->client = client.
IF state_handling( ).
RETURN.
ENDIF.

IF client->check_on_navigated( ).
DATA(view) = z2ui5_cl_xml_view=>factory( ).
view->_z2ui5( )->history( client->_bind( mv_search ) ).
client->view_display( val = view->shell(
)->page(
title = 'abap2UI5 - Navigation with app state'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = client->check_app_prev_stack( )
)->simple_form( title = 'Form Title' editable = abap_true
)->content( 'form'
)->title( 'Input'
)->label( 'quantity'
)->input( client->_bind_edit( mv_quantity )
)->label( `product`
)->input( client->_bind_edit( mv_product )
)->button(
text = 'post'
press = client->_event( val = 'BUTTON_POST' )
)->stringify( ) ).
ENDIF.

client->message_toast_display( `data updated` ).
ENDMETHOD.


METHOD state_handling.

IF client->check_on_init( ).
"we check if an app state is already set, if yes leave to this state (draft)
TRY.
mt_search = z2ui5_cl_util=>url_param_get_tab( client->get( )-s_config-search ).
DATA(lv_id) = mt_search[ n = `z2ui5-xapp-state` ]-v.
client->nav_app_leave( client->get_app( lv_id ) ).
result = abap_true.
RETURN.
CATCH cx_root.
ENDTRY.
ENDIF.

"set the url parameter with the actual app state id (draft)
DELETE mt_search WHERE n = `z2ui5-xapp-state`.
INSERT VALUE #( n = `z2ui5-xapp-state` v = client->get( )-s_draft-id ) INTO TABLE mt_search.
mv_search = `?` && z2ui5_cl_util=>url_param_create_url( mt_search ).
client->view_model_update( ).

ENDMETHOD.

ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_321.clas.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_DEMO_APP_321</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Navigation - app state</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
Loading