Skip to content

Commit 2b3b748

Browse files
authored
update
1 parent e76af47 commit 2b3b748

12 files changed

+1140
-0
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
CLASS z2ui5_cl_cc_sample_message_m DEFINITION
2+
PUBLIC
3+
CREATE PUBLIC .
4+
5+
PUBLIC SECTION.
6+
7+
INTERFACES z2ui5_if_app .
8+
9+
TYPES:
10+
BEGIN OF ty_s_item,
11+
message TYPE string,
12+
description TYPE string,
13+
type TYPE string,
14+
target TYPE string,
15+
additionaltext TYPE string,
16+
date TYPE string,
17+
descriptionurl TYPE string,
18+
persistent TYPE string,
19+
END OF ty_s_item .
20+
TYPES ty_t_items TYPE STANDARD TABLE OF ty_s_item WITH EMPTY KEY ##NEEDED.
21+
22+
DATA mt_messaging TYPE ty_t_items.
23+
24+
"string - constraints
25+
DATA: mv_maxlength_string TYPE string,
26+
mv_minlength_string TYPE string,
27+
mv_startswith_string TYPE string,
28+
mv_startswithignorecase_string TYPE string,
29+
mv_endswith_string TYPE string,
30+
mv_endswithignorecase_string TYPE string,
31+
mv_contains_string TYPE string,
32+
mv_equals_string TYPE string,
33+
mv_search_string TYPE string.
34+
35+
"integer - formatOptions
36+
DATA: mv_minintegerdigits_int TYPE string,
37+
mv_maxintegerdigits_int TYPE string,
38+
mv_groupingenabled_int TYPE string,
39+
mv_groupingseparator_int TYPE string.
40+
41+
"integer - constraints
42+
DATA: mv_maximum_int TYPE string,
43+
mv_minimum_int TYPE string.
44+
45+
"integer - formatOptions
46+
DATA: mv_minfractiondigits_float TYPE string,
47+
mv_maxfractiondigits_float TYPE string,
48+
mv_decimalseparator_float TYPE string.
49+
50+
"integer - constraints
51+
DATA: mv_maximum_float TYPE string,
52+
mv_minimum_float TYPE string.
53+
54+
"date - constraints
55+
DATA: mv_maximum_date TYPE string,
56+
mv_minimum_date TYPE string.
57+
58+
DATA mv_input_master TYPE string.
59+
DATA check_initialized TYPE abap_bool .
60+
METHODS z2ui5_display_view .
61+
62+
PROTECTED SECTION.
63+
64+
DATA client TYPE REF TO z2ui5_if_client.
65+
66+
PRIVATE SECTION.
67+
ENDCLASS.
68+
69+
70+
71+
CLASS z2ui5_cl_cc_sample_message_m IMPLEMENTATION.
72+
73+
METHOD z2ui5_display_view.
74+
75+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
76+
view->_z2ui5( )->message_manager( client->_bind_edit( mt_messaging ) ).
77+
DATA(page) = view->shell(
78+
)->page( class = `sapUiContentPadding `
79+
title = 'abap2UI5 - Input Validation'
80+
navbuttonpress = client->_event( val = 'BACK' )
81+
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
82+
).
83+
84+
"string
85+
page->flex_box( justifycontent = `SpaceAround` )->panel( headertext = `sap.ui.model.type.String`
86+
)->vbox(
87+
)->title( text = `CONSTRAINTS` level = `H3`
88+
)->vbox(
89+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
90+
)->label( text = `maxLength (5)`
91+
)->input( id = `testINPUT` value = `{path:'` && client->_bind_edit( val = mv_maxlength_string path = abap_true ) && `',type: 'sap.ui.model.type.String', constraints:{ maxLength: 5 } }`
92+
editable = abap_true
93+
class = `sapUiTinyMarginBeginEnd`
94+
)->input( id = `inputMain`
95+
value = `{path:'` && client->_bind_edit( val = mv_input_master path = abap_true ) && `',type:'sap.ui.model.type.String', constraints: { maxLength: 3 } }`
96+
)->get_parent(
97+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
98+
)->label( text = `minLength (3)`
99+
)->input( value = `{path:'` && client->_bind_edit( val = mv_minlength_string path = abap_true ) && `',type: 'sap.ui.model.type.String', constraints:{ minLength: 3 } }`
100+
editable = abap_true
101+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
102+
103+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
104+
)->label( text = `startsWith (a2ui5)`
105+
)->input( value = `{path:'` && client->_bind_edit( val = mv_startswith_string path = abap_true ) && `',type: 'sap.ui.model.type.String', constraints:{ startsWith: 'a2ui5' } }`
106+
editable = abap_true
107+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
108+
109+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
110+
)->label( text = `startsWithIgnoreCase (a2ui5)`
111+
)->input( value = `{path:'` && client->_bind_edit( val = mv_startswithignorecase_string path = abap_true ) && `',type: 'sap.ui.model.type.String', constraints:{ startsWithIgnoreCase: 'a2ui5' } }`
112+
editable = abap_true
113+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
114+
115+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
116+
)->label( text = `endsWith (a2ui5)`
117+
)->input( value = `{path:'` && client->_bind_edit( val = mv_endswith_string path = abap_true ) && `',type: 'sap.ui.model.type.String', constraints:{ endsWith: 'a2ui5' } }`
118+
editable = abap_true
119+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
120+
121+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
122+
)->label( text = `endsWithIgnoreCase (a2ui5)`
123+
)->input( value = `{path:'` && client->_bind_edit( val = mv_endswithignorecase_string path = abap_true ) && `',type: 'sap.ui.model.type.String', constraints:{ endsWithIgnoreCase: 'a2ui5' } }`
124+
editable = abap_true
125+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
126+
127+
)->get_parent( )->get_parent( )->get_parent(
128+
)->panel( headertext = `sap.ui.model.type.Integer`
129+
)->vbox(
130+
)->title( text = `FORMAT OPTIONS and CONSTRAINTS` level = `H3`
131+
)->vbox(
132+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
133+
)->label( text = `minIntegerDigits (1)`
134+
)->input( value = `{path:'` && client->_bind_edit( val = mv_minintegerdigits_int path = abap_true ) && `',type: 'sap.ui.model.type.Integer', formatOptions:{ minIntegerDigits: 1 }, constraints:{ maximum: 10 } }`
135+
editable = abap_true
136+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
137+
138+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
139+
)->label( text = `maxIntegerDigits (3)`
140+
)->input( value = `{path:'` && client->_bind_edit( val = mv_maxintegerdigits_int path = abap_true ) && `',type: 'sap.ui.model.type.Integer', formatOptions:{ maxIntegerDigits: 3 }, constraints:{ minimum: 100 } }`
141+
editable = abap_true
142+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
143+
144+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
145+
)->label( text = `groupingEnabled`
146+
)->input( value = `{path:'` && client->_bind_edit( val = mv_groupingenabled_int path = abap_true ) && `',type: 'sap.ui.model.type.Integer', formatOptions:{ groupingEnabled: true } }`
147+
editable = abap_true
148+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
149+
150+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
151+
)->label( text = `groupingSeparator (-)`
152+
)->input( value = `{path:'` && client->_bind_edit( val = mv_groupingseparator_int path = abap_true ) && `',type: 'sap.ui.model.type.Integer', formatOptions:{ groupingEnabled: true, groupingSeparator: '-' } }`
153+
editable = abap_true
154+
class = `sapUiTinyMarginBeginEnd` )->get_parent(
155+
156+
157+
)->get_parent( )->get_parent( )->get_parent(
158+
)->panel( headertext = `sap.ui.model.type.Float`
159+
)->vbox(
160+
)->title( text = `FORMAT OPTIONS and CONSTRAINTS` level = `H3`
161+
)->vbox(
162+
)->hbox( class = `sapUiTinyMarginTopBottom` alignitems = `Center`
163+
)->label( text = `minFractionDigits (2)`
164+
)->input( value = `{path:'` && client->_bind_edit( val = mv_minfractiondigits_float path = abap_true ) && `',type: 'sap.ui.model.type.Float', formatOptions:{ minFractionDigits: 2 } }`
165+
editable = abap_true
166+
class = `sapUiTinyMarginBeginEnd` ).
167+
168+
client->view_display( view->stringify( ) ).
169+
170+
ENDMETHOD.
171+
172+
173+
METHOD z2ui5_if_app~main.
174+
175+
me->client = client.
176+
177+
IF check_initialized = abap_false.
178+
check_initialized = abap_true.
179+
180+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
181+
client->view_display(
182+
view->_generic( ns = `html` name = `script` )->_cc_plain_xml( z2ui5_cl_cc_message_m=>get_js( )
183+
)->_z2ui5( )->timer( client->_event( `ON_CC_LOADED` )
184+
)->stringify( ) ).
185+
186+
ENDIF.
187+
188+
CASE client->get( )-event.
189+
WHEN 'ON_CC_LOADED'.
190+
z2ui5_display_view( ).
191+
WHEN 'BACK'.
192+
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
193+
ENDCASE.
194+
195+
ENDMETHOD.
196+
ENDCLASS.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<VSEOCLASS>
6+
<CLSNAME>Z2UI5_CL_CC_SAMPLE_MESSAGE_M</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>more - input validation &amp; message manager</DESCRIPT>
9+
<STATE>1</STATE>
10+
<CLSCCINCL>X</CLSCCINCL>
11+
<FIXPT>X</FIXPT>
12+
<UNICODE>X</UNICODE>
13+
</VSEOCLASS>
14+
</asx:values>
15+
</asx:abap>
16+
</abapGit>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
CLASS z2ui5_cl_cc_sample_validator DEFINITION
2+
PUBLIC
3+
FINAL
4+
CREATE PUBLIC .
5+
6+
PUBLIC SECTION.
7+
8+
INTERFACES if_serializable_object .
9+
INTERFACES z2ui5_if_app .
10+
11+
DATA check_initialized TYPE abap_bool .
12+
DATA ls_validation_schema TYPE z2ui5_cl_cc_validator=>ty_validation_schema .
13+
DATA mv_email TYPE string .
14+
DATA mv_number TYPE int4 .
15+
PROTECTED SECTION.
16+
17+
DATA client TYPE REF TO z2ui5_if_client.
18+
19+
METHODS display_view.
20+
PRIVATE SECTION.
21+
ENDCLASS.
22+
23+
24+
25+
CLASS Z2UI5_CL_CC_SAMPLE_VALIDATOR IMPLEMENTATION.
26+
27+
28+
METHOD display_view.
29+
30+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
31+
32+
view->_generic( ns = `html` name = `script` )->_cc_plain_xml( z2ui5_cl_cc_validator=>get_js( is_validation = ls_validation_schema iv_view = 'MAIN' ) )->get_parent( ).
33+
34+
DATA(page) = view->shell( )->page( showheader = abap_false ).
35+
page->simple_form( title = 'Validator' editable = abap_true
36+
)->content( 'form'
37+
)->label( `email`
38+
)->input( value = client->_bind_edit( mv_email ) width = `15rem` id = `email`
39+
)->label( `number > 0`
40+
)->input( value = client->_bind_edit( mv_number ) width = `15rem` id = `number`
41+
)->button( text = `Submit` press = client->_event( 'CHECK_FORM' )
42+
).
43+
44+
45+
client->view_display( view->stringify( ) ).
46+
47+
ENDMETHOD.
48+
49+
50+
METHOD z2ui5_if_app~main.
51+
52+
me->client = client.
53+
54+
IF check_initialized = abap_false.
55+
check_initialized = abap_true.
56+
57+
58+
ls_validation_schema-properties-number-type = `number`.
59+
ls_validation_schema-properties-number-minimum = 1.
60+
ls_validation_schema-properties-number-max_length = 999999.
61+
62+
ls_validation_schema-properties-email-type = `string`.
63+
ls_validation_schema-properties-email-format = `email`.
64+
ls_validation_schema-properties-email-min_length = 0.
65+
66+
67+
client->view_display( z2ui5_cl_xml_view=>factory(
68+
)->_z2ui5( )->timer( finished = client->_event( `START` ) delayms = `0`
69+
)->_generic( ns = `html` name = `script` )->_cc_plain_xml( z2ui5_cl_cc_validator=>load_ajv( )
70+
)->stringify( ) ).
71+
72+
RETURN.
73+
ENDIF.
74+
75+
76+
CASE client->get( )-event.
77+
WHEN 'START'.
78+
display_view( ).
79+
WHEN 'BACK'.
80+
client->nav_app_leave( ).
81+
WHEN 'CHECK_FORM'.
82+
client->follow_up_action( z2ui5_cl_cc_validator=>validate_fields( ) ).
83+
ENDCASE.
84+
client->view_model_update( ).
85+
ENDMETHOD.
86+
ENDCLASS.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<VSEOCLASS>
6+
<CLSNAME>Z2UI5_CL_CC_SAMPLE_VALIDATOR</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>validator - demo</DESCRIPT>
9+
<STATE>1</STATE>
10+
<CLSCCINCL>X</CLSCCINCL>
11+
<FIXPT>X</FIXPT>
12+
<UNICODE>X</UNICODE>
13+
</VSEOCLASS>
14+
</asx:values>
15+
</asx:abap>
16+
</abapGit>

0 commit comments

Comments
 (0)