binding on structure level (#815)

This commit is contained in:
oblomov 2024-01-25 14:00:33 +01:00 committed by GitHub
parent a117201de5
commit 02af594f49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 69 additions and 3 deletions

View File

@ -29,6 +29,16 @@ CLASS z2ui5_cl_fw_client DEFINITION
RETURNING
VALUE(r_result) TYPE string.
METHODS bind_struc_comp
IMPORTING
iv_name TYPE string
i_struc type data
* i_tab_index TYPE i
* i_tab TYPE STANDARD TABLE
i_val TYPE data
RETURNING
VALUE(r_result) TYPE string.
PRIVATE SECTION.
ENDCLASS.
@ -37,6 +47,35 @@ ENDCLASS.
CLASS z2ui5_cl_fw_client IMPLEMENTATION.
METHOD bind_struc_comp.
FIELD-SYMBOLS <ele> TYPE any.
FIELD-SYMBOLS <row> TYPE any.
DATA lr_ref_in TYPE REF TO data.
DATA lr_ref TYPE REF TO data.
ASSIGN i_struc TO <row>.
DATA(lt_attri) = z2ui5_cl_util_func=>rtti_get_t_comp_by_data( i_struc ).
LOOP AT lt_attri ASSIGNING FIELD-SYMBOL(<comp>).
ASSIGN COMPONENT <comp>-name OF STRUCTURE <row> TO <ele>.
lr_ref_in = REF #( <ele> ).
lr_ref = REF #( i_val ).
IF lr_ref = lr_ref_in.
r_result = `{` && iv_name && '/' && <comp>-name && `}`.
RETURN.
ENDIF.
ENDLOOP.
RAISE EXCEPTION TYPE z2ui5_cx_util_error
EXPORTING
val = `BINDING_ERROR - No class attribute for binding found - Please check if the binded values are public attributes of your class`.
ENDMETHOD.
METHOD bind_tab_cell.
FIELD-SYMBOLS <ele> TYPE any.
@ -274,6 +313,18 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
RETURN.
ENDIF.
IF struc IS NOT INITIAL.
DATA(lv_name_struc) = z2ui5_if_client~_bind_edit( val = struc path = abap_true pretty_name = pretty_name ).
result = bind_struc_comp(
iv_name = lv_name_struc
i_struc = struc
i_val = val ).
RETURN.
ENDIF.
DATA(lo_binder) = z2ui5_cl_fw_binding=>factory(
app = mo_handler->ms_db-app
attri = mo_handler->ms_db-t_attri
@ -328,6 +379,19 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
i_val = val ).
RETURN.
ENDIF.
IF struc IS NOT INITIAL.
DATA(lv_name_struc) = z2ui5_if_client~_bind_edit( val = struc path = abap_true pretty_name = pretty_name ).
result = bind_struc_comp(
iv_name = lv_name_struc
i_struc = struc
i_val = val ).
RETURN.
ENDIF.

View File

@ -24,8 +24,8 @@ INTERFACE z2ui5_if_client
main TYPE string VALUE `MAIN`,
nested TYPE string VALUE `NEST`,
nested2 TYPE string VALUE `NEST2`,
popover TYPE string VALUE `POPOVER`,
popup TYPE string VALUE `POPUP`,
* popover TYPE string VALUE `POPOVER`,
* popup TYPE string VALUE `POPUP`,
END OF cs_view.
CONSTANTS:
@ -174,6 +174,7 @@ INTERFACE z2ui5_if_client
compress TYPE clike DEFAULT cs_compress_mode-standard
tab TYPE STANDARD TABLE OPTIONAL
tab_index TYPE i OPTIONAL
struc TYPE data OPTIONAL
RETURNING
VALUE(result) TYPE string.
@ -186,6 +187,7 @@ INTERFACE z2ui5_if_client
compress TYPE clike DEFAULT cs_compress_mode-standard
tab TYPE STANDARD TABLE OPTIONAL
tab_index TYPE i OPTIONAL
struc TYPE data OPTIONAL
RETURNING
VALUE(result) TYPE string.