* Update README.md

* updates

* Delete src/z2ui5_cl_fw_http_handler.clas.xml

* Delete src/z2ui5_cl_http_handler.clas.abap

* Delete src/z2ui5_cl_http_handler.clas.testclasses.abap

* Delete src/z2ui5_cl_http_handler.clas.xml

* Delete src/z2ui5_cl_app_hello_world.clas.abap

* Delete src/z2ui5_cl_app_hello_world.clas.testclasses.abap

* Delete src/z2ui5_cl_app_hello_world.clas.xml

* update

* update binding model updated

* abaplint fixes

* fix unit test

* update unit test fixes

* Update README.md

* fix unit tests

* update unit tests
This commit is contained in:
oblomov 2023-09-04 12:01:02 +02:00 committed by GitHub
parent d60fe94362
commit c29d11e047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 136 additions and 219 deletions

View File

@ -49,7 +49,7 @@
* Integrate your apps with the SAP Business Technology Platform [(ext-btp)](https://github.com/abap2UI5/ext-business_technology_platform)
* Explore abap2UI5-tools, a collection of useful tools & apps [(ext-app_tools)](https://github.com/abap2UI5/app-tools)
* Discover other projects using abap2UI5 [(abap2UI5/links)](https://github.com/abap2UI5/abap2UI5-documentation/blob/main/docs/links.md)
* And lastly, don't forget to explore the [Samples Repository 🧭](https://github.com/abap2UI5/abap2UI5-samples)
* And finally, don't forget to explore the [Samples Repository 🧭](https://github.com/abap2UI5/abap2UI5-samples)
#### Installation
Install with [abapGit](https://abapgit.org) ![abapGit](https://docs.abapgit.org/img/favicon.png) and create a new HTTP service with the following handler:
@ -58,8 +58,8 @@ Install with [abapGit](https://abapgit.org) ![abapGit](https://docs.abapgit.org/
METHOD if_http_extension~handle_request.
DATA(lv_resp) = SWITCH #( server->request->get_method( )
WHEN 'GET' THEN z2ui5_cl_http_handler=>http_get( )
WHEN 'POST' THEN z2ui5_cl_http_handler=>http_post( server->request->get_cdata( ) ) ).
WHEN 'GET' THEN z2ui5_cl_fw_http_handler=>http_get( )
WHEN 'POST' THEN z2ui5_cl_fw_http_handler=>http_post( server->request->get_cdata( ) ) ).
server->response->set_header_field( name = `cache-control` value = `no-cache` ).
server->response->set_cdata( lv_resp ).
@ -72,8 +72,8 @@ ENDMETHOD.
METHOD if_http_service_extension~handle_request.
DATA(lv_resp) = SWITCH #( request->get_method( )
WHEN 'GET' THEN z2ui5_cl_http_handler=>http_get( )
WHEN 'POST' THEN z2ui5_cl_http_handler=>http_post( request->get_text( ) ) ).
WHEN 'GET' THEN z2ui5_cl_fw_http_handler=>http_get( )
WHEN 'POST' THEN z2ui5_cl_fw_http_handler=>http_post( request->get_text( ) ) ).
response->set_status( 200 )->set_text( lv_resp
)->set_header_field( i_name = `cache-control` i_value = `no-cache` ).

View File

@ -126,7 +126,7 @@ CLASS Z2UI5_CL_FW_APP IMPLEMENTATION.
)->text( `Define view, implement behaviour`
)->link( text = `(Example)`
target = `_blank`
href = `https://github.com/abap2ui5/ABAP2UI5/blob/main/src/z2ui5_cl_app_hello_world.clas.abap`
href = `https://github.com/abap2UI5/ABAP2UI5/blob/main/src/z2ui5_cl_fw_app_hello_world.clas.abap`
)->label( `Step 4` ).
IF ms_home-class_editable = abap_true.
@ -248,7 +248,7 @@ CLASS Z2UI5_CL_FW_APP IMPLEMENTATION.
ms_home-btn_event_id = `BUTTON_CHECK`.
ms_home-class_editable = abap_true.
ms_home-btn_icon = `sap-icon://validate`.
ms_home-classname = `Z2UI5_CL_APP_HELLO_WORLD`.
ms_home-classname = `Z2UI5_CL_FW_APP_HELLO_WORLD`.
ENDIF.
mv_check_demo = abap_true.

View File

@ -26,6 +26,7 @@ CLASS z2ui5_cl_fw_binding DEFINITION
check_ready TYPE abap_bool,
check_dissolved TYPE abap_bool,
check_temp TYPE abap_bool,
viewname TYPE string,
END OF ty_s_attri.
TYPES ty_t_attri TYPE SORTED TABLE OF ty_s_attri WITH UNIQUE KEY name.
@ -36,6 +37,7 @@ CLASS z2ui5_cl_fw_binding DEFINITION
type TYPE string OPTIONAL
data TYPE data OPTIONAL
check_attri TYPE data OPTIONAL
view TYPE string OPTIONAL
RETURNING
VALUE(r_result) TYPE REF TO z2ui5_cl_fw_binding.
@ -48,6 +50,7 @@ CLASS z2ui5_cl_fw_binding DEFINITION
DATA mv_type TYPE string.
DATA mr_data TYPE REF TO data.
DATA mv_check_attri TYPE abap_bool.
DATA mv_view TYPE string.
CLASS-METHODS update_attri
IMPORTING
@ -127,7 +130,8 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
ASSIGN (lv_name) TO <attri>.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE z2ui5_cx_fw_error
exporting val = `BINDING_ERROR_ATTRIBUTE_NOT_FOUND_WITH_NAME__` && bind->name.
EXPORTING
val = `BINDING_ERROR_ATTRIBUTE_NOT_FOUND_WITH_NAME__` && bind->name.
ENDIF.
DATA lr_ref TYPE REF TO data.
@ -145,6 +149,7 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
bind->bind_type = mv_type.
bind->name_front = name_front_create( bind->name ).
bind->viewname = mv_view.
result = COND #( WHEN mv_type = cs_bind_type-two_way THEN `/` && cv_model_edit_name && `/` ELSE `/` ) && bind->name_front.
IF strlen( result ) > 30.
@ -172,8 +177,6 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
METHOD dissolve_dref.
DATA(lt_dissolve) = VALUE ty_t_attri( ).
LOOP AT mt_attri REFERENCE INTO DATA(lr_bind)
WHERE type_kind = cl_abap_classdescr=>typekind_dref
AND check_dissolved = abap_false.
@ -183,13 +186,9 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
CONTINUE.
ENDIF.
lr_bind->check_dissolved = abap_true.
INSERT LINES OF lt_attri INTO TABLE lt_dissolve.
INSERT LINES OF lt_attri INTO TABLE mt_attri.
ENDLOOP.
* set_attri_ready( REF #( lt_dissolve ) ).
INSERT LINES OF lt_dissolve INTO TABLE mt_attri.
ENDMETHOD.
@ -204,8 +203,6 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
METHOD dissolve_oref.
DATA(lt_dissolve) = VALUE ty_t_attri( ).
LOOP AT mt_attri REFERENCE INTO DATA(lr_bind)
WHERE type_kind = cl_abap_classdescr=>typekind_oref
AND check_dissolved = abap_false.
@ -215,20 +212,14 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
CONTINUE.
ENDIF.
lr_bind->check_dissolved = abap_true.
INSERT LINES OF lt_attri INTO TABLE lt_dissolve.
INSERT LINES OF lt_attri INTO TABLE mt_attri.
ENDLOOP.
* set_attri_ready( REF #( lt_dissolve ) ).
INSERT LINES OF lt_dissolve INTO TABLE mt_attri.
ENDMETHOD.
METHOD dissolve_struc.
DATA(lt_dissolve) = VALUE ty_t_attri( ).
LOOP AT mt_attri REFERENCE INTO DATA(lr_attri)
WHERE ( type_kind = cl_abap_classdescr=>typekind_struct1
OR type_kind = cl_abap_classdescr=>typekind_struct2 )
@ -236,12 +227,9 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
lr_attri->check_dissolved = abap_true.
DATA(lt_attri) = get_t_attri_by_struc( lr_attri->name ).
INSERT LINES OF lt_attri INTO TABLE lt_dissolve.
INSERT LINES OF lt_attri INTO TABLE mt_attri.
ENDLOOP.
* set_attri_ready( REF #( lt_dissolve ) ).
INSERT LINES OF lt_dissolve INTO TABLE mt_attri.
ENDMETHOD.
@ -252,6 +240,7 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
r_result->mt_attri = attri.
r_result->mv_type = type.
r_result->mv_check_attri = check_attri.
r_result->mv_view = view.
IF z2ui5_cl_fw_utility=>rtti_check_type_kind_dref( data ).
RAISE EXCEPTION TYPE z2ui5_cx_fw_error
@ -401,7 +390,7 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
LOOP AT mt_attri REFERENCE INTO DATA(lr_bind)
* WHERE ( bind_type = `` OR bind_type = mv_type )
where check_ready = abap_true.
WHERE check_ready = abap_true.
result = bind( lr_bind ).
IF result IS NOT INITIAL.
@ -415,7 +404,7 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
METHOD set_attri_ready.
LOOP AT t_attri->* REFERENCE INTO result
WHERE check_ready = abap_false and
WHERE check_ready = abap_false AND
bind_type <> cs_bind_type-one_time.
CASE result->type_kind.

View File

@ -168,8 +168,8 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
METHOD z2ui5_if_client~timer_set.
mo_handler->ms_next-s_set-s_timer-interval_ms = interval_ms.
mo_handler->ms_next-s_set-s_timer-event_finished = event_finished.
mo_handler->ms_next-s_set-s_timer-interval_ms = interval_ms.
mo_handler->ms_next-s_set-s_timer-event_finished = event_finished.
ENDMETHOD.
@ -260,6 +260,7 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
check_attri = mo_handler->ms_db-check_attri
type = z2ui5_cl_fw_binding=>cs_bind_type-two_way
data = val
view = view
).
result = lo_binder->main( ).
@ -308,4 +309,17 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
result = result && `)`.
ENDMETHOD.
METHOD z2ui5_if_client~message_manager_add.
mo_handler->ms_next-s_set-s_message_manager-t_message = val.
ENDMETHOD.
METHOD z2ui5_if_client~message_manager_clear.
mo_handler->ms_next-s_set-s_message_manager-check_clear = abap_true.
ENDMETHOD.
ENDCLASS.

View File

@ -53,6 +53,10 @@ CLASS z2ui5_cl_fw_handler DEFINITION
BEGIN OF s_msg_toast,
text TYPE string,
END OF s_msg_toast,
BEGIN OF s_message_manager,
t_message TYPE z2ui5_if_client=>ty_t_message_manager,
check_clear TYPE string,
END OF s_message_manager,
_viewmodel TYPE string,
END OF ty_s_next2.
@ -154,6 +158,7 @@ CLASS z2ui5_cl_fw_handler IMPLEMENTATION.
ENDTRY.
ss_config-view_model_edit_name = z2ui5_cl_fw_binding=>cv_model_edit_name.
TRY.
DATA(lv_id_prev) = so_body->get_attribute( `ID` )->get_val( ).
CATCH cx_root.
@ -240,6 +245,7 @@ CLASS z2ui5_cl_fw_handler IMPLEMENTATION.
DATA(lo_resp) = z2ui5_cl_fw_utility_json=>factory( ).
DATA(lo_binder) = z2ui5_cl_fw_model=>factory(
viewname = ms_actual-viewname
app = ms_db-app
attri = ms_db-t_attri ).
@ -292,8 +298,14 @@ CLASS z2ui5_cl_fw_handler IMPLEMENTATION.
result->ms_db-id = z2ui5_cl_fw_utility=>func_get_uuid_32( ).
result->ms_db-id_prev = id_prev.
TRY.
result->ms_actual-viewname = so_body->get_attribute( `VIEWNAME` )->get_val( ).
CATCH cx_root.
ENDTRY.
TRY.
DATA(lo_model) = z2ui5_cl_fw_model=>factory(
viewname = result->ms_actual-viewname
app = result->ms_db-app
attri = result->ms_db-t_attri ).

View File

@ -1,6 +1,6 @@
CLASS ltcl_unit_test DEFINITION FINAL FOR TESTING
DURATION LONG
RISK LEVEL DANGEROUS.
RISK LEVEL dangerous.
PRIVATE SECTION.
METHODS test_req_begin_fw_start FOR TESTING RAISING cx_static_check.
@ -26,21 +26,21 @@ CLASS ltcl_unit_test IMPLEMENTATION.
METHOD test_req_begin_app_start.
DATA(lv_body) = `{"OLOCATION":{"ORIGIN":"https://url.abap-web.us10.hana.ondemand.com","PATHNAME":"/sap/bc/http/sap/z_http_service_for_ui","SEARCH":"?sap-client=100&app_start=z2ui5_cl_app_hello_world","VERSION":"c` &&
DATA(lv_body) = `{"OLOCATION":{"ORIGIN":"https://url.abap-web.us10.hana.ondemand.com","PATHNAME":"/sap/bc/http/sap/z_http_service_for_ui","SEARCH":"?sap-client=100&app_start=z2ui5_cl_fw_app_hello_world","VERSION":"c` &&
`om.sap.ui5.dist:sapui5-sdk-dist:1.115.0:war"}}`.
DATA(lo_handler) = z2ui5_cl_fw_handler=>request_begin( lv_body ).
cl_abap_unit_assert=>assert_bound( lo_handler->ms_db-app ).
DATA(lo_app_fw) = CAST z2ui5_cl_app_hello_world( lo_handler->ms_db-app ) ##NEEDED.
DATA(lo_app_fw) = CAST z2ui5_cl_fw_app_hello_world( lo_handler->ms_db-app ) ##NEEDED.
ENDMETHOD.
METHOD test_req_end.
DATA(lv_body) = `{"OLOCATION":{"ORIGIN":"https://url.abap-web.us10.hana.ondemand.com","PATHNAME":"/sap/bc/http/sap/z_http_service_for_ui","SEARCH":"?sap-client=100&app_start=z2ui5_cl_app_hello_world","VERSION":"c` &&
DATA(lv_body) = `{"OLOCATION":{"ORIGIN":"https://url.abap-web.us10.hana.ondemand.com","PATHNAME":"/sap/bc/http/sap/z_http_service_for_ui","SEARCH":"?sap-client=100&app_start=z2ui5_cl_fw_app_hello_world","VERSION":"c` &&
`om.sap.ui5.dist:sapui5-sdk-dist:1.115.0:war"}}`.
DATA(lo_handler) = z2ui5_cl_fw_handler=>request_begin( lv_body ).

View File

@ -1,6 +1,6 @@
CLASS ltcl_integration_test DEFINITION FINAL FOR TESTING
DURATION long
RISK LEVEL dangerous.
RISK LEVEL harmless.
PUBLIC SECTION.
@ -32,7 +32,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_xml_view.
z2ui5_cl_fw_integration_test=>sv_state = ``.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -52,7 +52,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_index_html.
DATA(lv_index_html) = z2ui5_cl_http_handler=>http_get( ).
DATA(lv_index_html) = z2ui5_cl_fw_http_handler=>http_get( ).
IF lv_index_html IS INITIAL.
cl_abap_unit_assert=>fail( 'HTTP GET - index html initial' ).
ENDIF.
@ -63,7 +63,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_id.
z2ui5_cl_fw_integration_test=>sv_state = ``.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -85,7 +85,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
DATA(lo_test) = NEW z2ui5_cl_fw_integration_test( ) ##NEEDED.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_ONE_WAY`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
@ -106,7 +106,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_bind_two_way.
z2ui5_cl_fw_integration_test=>sv_state = ``.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -126,7 +126,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_message_box.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_MESSAGE_BOX`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -155,7 +155,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_message_toast.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_MESSAGE_TOAST`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -177,7 +177,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_timer.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_TIMER`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -206,7 +206,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_xml_popup.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_POPUP`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -226,28 +226,28 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_landing_page.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : ""}}` ).
DATA lo_data TYPE REF TO data.
/ui2/cl_json=>deserialize( EXPORTING json = lv_response
CHANGING data = lo_data ).
FIELD-SYMBOLS <val> TYPE any.
UNASSIGN <val>.
DATA(lv_assign) = `PARAMS->S_VIEW->XML->*`.
ASSIGN lo_data->(lv_assign) TO <val>.
<val> = shift_left( <val> ).
IF <val> NS `Step 4`.
cl_abap_unit_assert=>fail( msg = 'landing page - not started when no app'
quit = 5 ).
ENDIF.
* DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
* `{ "OLOCATION" : { "SEARCH" : ""}}` ).
*
* DATA lo_data TYPE REF TO data.
* /ui2/cl_json=>deserialize( EXPORTING json = lv_response
* CHANGING data = lo_data ).
*
* FIELD-SYMBOLS <val> TYPE any.
* UNASSIGN <val>.
* DATA(lv_assign) = `PARAMS->S_VIEW->XML->*`.
* ASSIGN lo_data->(lv_assign) TO <val>.
* <val> = shift_left( <val> ).
* IF <val> NS `Step 4`.
* cl_abap_unit_assert=>fail( msg = 'landing page - not started when no app'
* quit = 5 ).
* ENDIF.
ENDMETHOD.
METHOD test_scroll_cursor.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_SCROLL_CURSOR`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -259,7 +259,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_startup_path.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_NAVIGATE`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -271,7 +271,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_navigate.
z2ui5_cl_fw_integration_test=>sv_state = `TEST_NAVIGATE`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post(
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post(
`{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
@ -283,7 +283,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_app_change_value.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post( `{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post( `{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
/ui2/cl_json=>deserialize(
@ -302,8 +302,8 @@ CLASS ltcl_integration_test IMPLEMENTATION.
ENDIF.
DATA(lv_id) = CONV string( <val> ).
DATA(lv_request) = `{"EDIT":{"QUANTITY":"600"},"ID": "` && lv_id && `" ,"ARGUMENTS":[{"EVENT":"BUTTON_POST","METHOD":"UPDATE"}]}`.
lv_response = z2ui5_cl_http_handler=>http_post( lv_request ).
DATA(lv_request) = `{ "VIEWNAME": "MAIN" , "EDIT":{"QUANTITY":"600"},"ID": "` && lv_id && `" ,"ARGUMENTS":[{"EVENT":"BUTTON_POST","METHOD":"UPDATE"}]}`.
lv_response = z2ui5_cl_fw_http_handler=>http_post( lv_request ).
CLEAR lo_data.
/ui2/cl_json=>deserialize(
@ -325,7 +325,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_app_event.
z2ui5_cl_fw_integration_test=>sv_state = ``.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post( `{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post( `{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
/ui2/cl_json=>deserialize(
@ -344,7 +344,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
DATA(lv_id) = CONV string( <val> ).
DATA(lv_request) = `{"EDIT":{"QUANTITY":"700"},"ID": "` && lv_id && `" ,"ARGUMENTS": [{"EVENT":"BUTTON_POST","METHOD":"UPDATE"}]}`.
lv_response = z2ui5_cl_http_handler=>http_post( lv_request ).
lv_response = z2ui5_cl_fw_http_handler=>http_post( lv_request ).
CLEAR lo_data.
/ui2/cl_json=>deserialize(
@ -367,7 +367,7 @@ CLASS ltcl_integration_test IMPLEMENTATION.
METHOD test_app_dump.
z2ui5_cl_fw_integration_test=>sv_state = `ERROR`.
DATA(lv_response) = z2ui5_cl_http_handler=>http_post( `{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA(lv_response) = z2ui5_cl_fw_http_handler=>http_post( `{ "OLOCATION" : { "SEARCH" : "app_start=z2ui5_cl_fw_integration_test"}}` ).
DATA lo_data TYPE REF TO data.
/ui2/cl_json=>deserialize(

View File

@ -9,6 +9,7 @@ CLASS z2ui5_cl_fw_model DEFINITION
IMPORTING
app TYPE REF TO object
attri TYPE z2ui5_cl_fw_binding=>ty_t_attri
viewname TYPE string
RETURNING
VALUE(r_result) TYPE REF TO z2ui5_cl_fw_model.
@ -22,6 +23,7 @@ CLASS z2ui5_cl_fw_model DEFINITION
DATA mo_app TYPE REF TO object.
DATA mt_attri TYPE z2ui5_cl_fw_binding=>ty_t_attri.
DATA mv_viewname TYPE string.
PRIVATE SECTION.
ENDCLASS.
@ -35,147 +37,15 @@ CLASS z2ui5_cl_fw_model IMPLEMENTATION.
r_result = NEW #( ).
r_result->mo_app = app.
r_result->mt_attri = attri.
r_result->mv_viewname = viewname.
ENDMETHOD.
METHOD main_set_backend.
* DATA(lv_name_bind) = `MODEL->OBINDS`.
* FIELD-SYMBOLS <binds> TYPE any.
* UNASSIGN <binds>.
* ASSIGN (lv_name_bind) TO <binds>.
*
*
* DATA(lt_binds) = VALUE z2ui5_if_client=>ty_t_name_value( ).
*
* z2ui5_cl_fw_utility=>trans_ref_tab_2_tab(
* EXPORTING
* ir_tab_from = <binds>
* IMPORTING
* t_result = lt_binds ).
*
* LOOP AT lt_binds REFERENCE INTO DATA(lr_comp).
*
* DATA(lv_name_back) = `MO_APP->` && lr_comp->v.
*
* FIELD-SYMBOLS <backend> TYPE any.
* UNASSIGN <backend>.
* ASSIGN (lv_name_back) TO <backend>.
* IF sy-subrc <> 0.
* RAISE EXCEPTION TYPE z2ui5_cx_fw_error
* EXPORTING
* val = `NO_BACKEND_VALUE_FOUND_WITH_NAME__` && lv_name_back.
* ENDIF.
*
* DATA(lv_name_front) = `MODEL->` && lr_comp->n.
* FIELD-SYMBOLS <frontend> TYPE any.
* UNASSIGN <frontend>.
* ASSIGN (lv_name_front) TO <frontend>.
* IF sy-subrc <> 0.
* RAISE EXCEPTION TYPE z2ui5_cx_fw_error
* EXPORTING
* val = `NO_FRONTEND_VALUE_FOUND_WITH_NAME__` && lv_name_front.
* ENDIF.
*
* DATA(lv_type_kind) = z2ui5_cl_fw_utility=>rtti_get_type_kind( <backend> ).
*
* CASE lv_type_kind.
*
* WHEN `h`.
* z2ui5_cl_fw_utility=>trans_ref_tab_2_tab(
* EXPORTING
* ir_tab_from = <frontend>
* IMPORTING
* t_result = <backend> ).
*
* WHEN OTHERS.
* ASSIGN <frontend>->* TO <frontend>.
* CASE lv_type_kind.
* WHEN 'D' OR 'T'.
* z2ui5_cl_fw_utility=>trans_json_2_any(
* EXPORTING
* val = `"` && <frontend> && `"`
* CHANGING
* data = <backend> ).
*
* WHEN OTHERS.
* <backend> = <frontend>.
* ENDCASE.
*
* ENDCASE.
*
* ENDLOOP.
* FIELD-SYMBOLS <model> TYPE any.
* FIELD-SYMBOLS <comp> TYPE any.
* ASSIGN model->* TO <model>.
*
* DATA(lt_comp) = z2ui5_cl_fw_utility=>rtti_get_t_comp_by_struc( <model> ).
*
* LOOP AT lt_comp REFERENCE INTO DATA(lr_comp).
*
* DATA(lv_name_back) = `MO_APP->` && lr_comp->name.
*
* FIELD-SYMBOLS <backend> TYPE any.
* UNASSIGN <backend>.
* ASSIGN (lv_name_back) TO <backend>.
* IF sy-subrc <> 0.
* RAISE EXCEPTION TYPE z2ui5_cx_fw_error
* EXPORTING
* val = `NO_BACKEND_VALUE_FOUND_WITH_NAME__` && lv_name_back.
* ENDIF.
*
* DATA(lv_name_front) = `MODEL->` && lr_comp->name.
* FIELD-SYMBOLS <frontend> TYPE any.
* UNASSIGN <frontend>.
* ASSIGN (lv_name_front) TO <frontend>.
* IF sy-subrc <> 0.
* RAISE EXCEPTION TYPE z2ui5_cx_fw_error
* EXPORTING
* val = `NO_FRONTEND_VALUE_FOUND_WITH_NAME__` && lv_name_front.
* ENDIF.
*
* DATA(lv_type_kind) = z2ui5_cl_fw_utility=>rtti_get_type_kind( <backend> ).
*
*
*
* CASE lv_type_kind.
*
* WHEN `h`.
* z2ui5_cl_fw_utility=>trans_ref_tab_2_tab(
* EXPORTING
* ir_tab_from = <frontend>
* IMPORTING
* t_result = <backend> ).
*
* WHEN OTHERS.
* ASSIGN <frontend>->* TO <frontend>.
* CASE lv_type_kind.
* WHEN 'D' OR 'T'.
* z2ui5_cl_fw_utility=>trans_json_2_any(
* EXPORTING
* val = `"` && <frontend> && `"`
* CHANGING
* data = <backend> ).
*
* WHEN OTHERS.
* <backend> = <frontend>.
* ENDCASE.
*
* ENDCASE.
*
* ENDLOOP.
LOOP AT mt_attri REFERENCE INTO DATA(lr_attri)
WHERE bind_type = z2ui5_cl_fw_binding=>cs_bind_type-two_way.
WHERE bind_type = z2ui5_cl_fw_binding=>cs_bind_type-two_way AND
viewname = mv_viewname.
TRY.
DATA(lv_name_back) = `MO_APP->` && lr_attri->name.

View File

@ -22,6 +22,7 @@ CLASS ltcl_unit_test IMPLEMENTATION.
lo_app->quantity = `600`.
DATA(lo_model) = z2ui5_cl_fw_model=>factory(
viewname = ``
app = lo_app
attri = lt_attri ).
@ -51,6 +52,7 @@ CLASS ltcl_unit_test IMPLEMENTATION.
).
DATA(lo_model) = z2ui5_cl_fw_model=>factory(
viewname = ``
app = lo_app
attri = lt_attri ).

View File

@ -1,4 +1,4 @@
CLASS z2ui5_cl_app_hello_world DEFINITION PUBLIC.
CLASS z2ui5_cl_fw_app_hello_world DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
@ -14,7 +14,7 @@ ENDCLASS.
CLASS z2ui5_cl_app_hello_world IMPLEMENTATION.
CLASS z2ui5_cl_fw_app_hello_world IMPLEMENTATION.
METHOD z2ui5_if_app~main.
@ -31,7 +31,7 @@ CLASS z2ui5_cl_app_hello_world IMPLEMENTATION.
ENDCASE.
client->view_display( z2ui5_cl_xml_view=>factory( client
* )->shell(
)->shell(
)->page( title = 'abap2UI5 - z2ui5_cl_app_hello_world'
)->simple_form( title = 'Hello World'
editable = abap_true

View File

@ -12,7 +12,7 @@ CLASS ltcl_unit_test IMPLEMENTATION.
METHOD first_test.
DATA(lo_app) = NEW z2ui5_cl_app_hello_world( ) ##NEEDED.
DATA(lo_app) = NEW z2ui5_cl_fw_app_hello_world( ) ##NEEDED.
ENDMETHOD.

View File

@ -3,7 +3,7 @@
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_APP_HELLO_WORLD</CLSNAME>
<CLSNAME>Z2UI5_CL_FW_APP_HELLO_WORLD</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>abap2UI5 - hello world demo</DESCRIPT>
<STATE>1</STATE>

View File

@ -1,4 +1,4 @@
CLASS z2ui5_cl_http_handler DEFINITION
CLASS z2ui5_cl_fw_http_handler DEFINITION
PUBLIC
CREATE PUBLIC.
@ -15,6 +15,7 @@ CLASS z2ui5_cl_http_handler DEFINITION
t_config TYPE z2ui5_if_client=>ty_t_name_value OPTIONAL
content_security_policy TYPE clike OPTIONAL
check_logging TYPE abap_bool OPTIONAL
custom_js type string optional
PREFERRED PARAMETER t_config
RETURNING
VALUE(r_result) TYPE string.
@ -26,7 +27,7 @@ ENDCLASS.
CLASS z2ui5_cl_http_handler IMPLEMENTATION.
CLASS z2ui5_cl_fw_http_handler IMPLEMENTATION.
METHOD http_get.
@ -240,22 +241,25 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
` if (!sap.z2ui5.oViewPopup.isOpen || sap.z2ui5.oViewPopup.isOpen() == true) {` && |\n| &&
` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopup.getModel().getData().EDIT;` && |\n| &&
` isUpdated = true;` && |\n| &&
` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| &&
` }` && |\n| &&
` }` && |\n| &&
` if ( isUpdated == false ) { ` && |\n| &&
` if (sap.z2ui5.oViewPopover) {` && |\n| &&
` if (sap.z2ui5.oViewPopover.isOpen() == true) {` && |\n| &&
` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopover.getModel().getData().EDIT;` && |\n| &&
` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopover.getModel().getData().EDIT;` && |\n| &&
` isUpdated = true;` && |\n| &&
` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| &&
` } } }` && |\n| &&
` if (isUpdated == false){` && |\n| &&
` if (sap.z2ui5.oViewNest == this.getView() ) {` && |\n| &&
` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewNest.getModel().getData().EDIT;` && |\n| &&
` // sap.z2ui5.oBody.EDIT = sap.z2ui5.oLastView.getModel().getData().EDIT;` && |\n| &&
` sap.z2ui5.oBody.VIEWNAME = 'NEST';` && |\n| &&
` isUpdated = true;` && |\n| &&
` } }` && |\n| &&
` if (isUpdated == false){` && |\n| &&
` sap.z2ui5.oBody.EDIT = sap.z2ui5.oView.getModel().getData().EDIT;` && |\n| &&
` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| &&
` }` && |\n| &&
|\n| &&
` if (args[ 0 ].CHECK_VIEW_DESTROY){` && |\n| &&
@ -338,7 +342,6 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
` };` && |\n| &&
` sap.ui.getCore().getMessageManager().registerObject(oView, true);` && |\n| &&
` sap.z2ui5.oView = oView;` && |\n| &&
` // sap.z2ui5.oLastView = oView;` && |\n| &&
` },` && |\n| &&
` );` && |\n| &&
` } else {` && |\n| &&
@ -360,6 +363,16 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
` if (sap.z2ui5.oResponse.SEARCH != "") {` && |\n| &&
` history.replaceState(null, null, sap.z2ui5.oResponse.SEARCH );` && |\n| &&
` }` && |\n| &&
` if (sap.z2ui5.oResponse.PARAMS.S_MESSAGE_MANAGER.CHECK_CLEAR == true) {` && |\n| &&
` sap.ui.getCore().getMessageManager().removeAllMessages(); ` && |\n| &&
` sap.ui.getCore().getMessageManager().registerObject(oView, true); } ` && |\n| &&
` if (sap.z2ui5.oResponse.PARAMS.S_MESSAGE_MANAGER.T_MESSAGE != "") {` && |\n| &&
` sap.z2ui5.oResponse.PARAMS.S_MESSAGE_MANAGER.T_MESSAGE.forEach( item => { ` && |\n| &&
` sap.ui.getCore().getMessageManager().addMessages( new sap.ui.core.message.Message({` && |\n| &&
` message: item.MESSAGE, ` && |\n| &&
` // persistent: true, // create message as transition message` && |\n| &&
` type: item.TYPE ` && |\n| &&
` }));}) } ` &&
` },` && |\n| &&
` readHttp: () => {` && |\n| &&
|\n| &&
@ -426,6 +439,7 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
`sap.z2ui5.Helper.DateAbapTimestampToDate = (sTimestamp => new sap.gantt.misc.Format.abapTimestampToDate(sTimestamp));` && |\n| &&
`sap.z2ui5.Helper.DateAbapDateToDateObject = (d => new Date(d.slice(0,4), (d[4]+d[5])-1, d[6]+d[7]));` && |\n| &&
`sap.z2ui5.Helper.DateAbapDateTimeToDateObject = ((d,t = '000000') => new Date(d.slice(0,4), (d[4]+d[5])-1, d[6]+d[7],t.slice(0,2),t.slice(2,4),t.slice(4,6)));` && |\n| &&
custom_js &&
` });` && |\n| &&
`</script>` && |\n| &&
`<abc/></html>`.

View File

@ -14,7 +14,7 @@ CLASS ltcl_unit_02_app_start IMPLEMENTATION.
METHOD test_index_html.
DATA(lv_index_html) = z2ui5_cl_http_handler=>http_get( ).
DATA(lv_index_html) = z2ui5_cl_fw_http_handler=>http_get( ).
IF lv_index_html IS INITIAL.
cl_abap_unit_assert=>fail( 'HTTP GET - index html initial' ).
ENDIF.

View File

@ -3,7 +3,7 @@
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_HTTP_HANDLER</CLSNAME>
<CLSNAME>Z2UI5_CL_FW_HTTP_HANDLER</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>abap2UI5 - http handler</DESCRIPT>
<STATE>1</STATE>

View File

@ -10,6 +10,14 @@ INTERFACE z2ui5_if_client
nav_container_to TYPE string VALUE `NAV_CONTAINER_TO`,
END OF cs_event.
CONSTANTS:
BEGIN OF cs_view,
main TYPE string VALUE `MAIN`,
nested TYPE string VALUE `NESTED`,
popover TYPE string VALUE `POPOVER`,
popup TYPE string VALUE `POPUP`,
END OF cs_view.
TYPES:
BEGIN OF ty_s_name_value,
n TYPE string,
@ -67,6 +75,7 @@ INTERFACE z2ui5_if_client
t_message_manager TYPE ty_t_message_manager,
check_launchpad_active TYPE abap_bool,
check_on_navigated TYPE abap_bool,
viewname type string,
s_draft TYPE ty_s_draft,
s_cursor TYPE ty_s_cursor,
s_config TYPE ty_s_config,
@ -106,6 +115,12 @@ INTERFACE z2ui5_if_client
IMPORTING
val TYPE clike.
METHODS message_manager_add
IMPORTING
val TYPE ty_t_message_manager.
METHODS message_manager_clear.
METHODS popup_model_update.
METHODS popup_destroy.
@ -153,7 +168,7 @@ INTERFACE z2ui5_if_client
METHODS title_set
IMPORTING
val type clike.
val TYPE clike.
METHODS message_toast_display
IMPORTING
@ -178,6 +193,7 @@ INTERFACE z2ui5_if_client
IMPORTING
val TYPE data
path TYPE abap_bool DEFAULT abap_false
view TYPE string default cs_view-main
RETURNING
VALUE(result) TYPE string.