Page 1 of 1

Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Mon Jul 30, 2018 9:12 pm
by Kazunori Kasahara
Our customer has been used the PRIM_EDIT class for input fields. Because they would like to dynamically control the maximum number of characters and allowed characters (SBCS/DBCS) that can be entered in input fields using the DataClass property.

They are considering to replace PRIM_EDIT fields to PRIM_MD.Edit fields for more better UI.
PRIM_MD.Edit doesn't have the DataClass property. PRIM_MD.Edit has the MaxLength property to control the maximum number of characters but doesn't have the property to control allowed characters (DBCS/SBCS).

We think that there is only way to check entered data in event routine. e.g. LostFocus
Is there is any other way or functionality to check allowed characters (DBCS/SBCS) for PRIM_MD.Edit field?

Thank you in advance.

Re: Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Tue Jul 31, 2018 9:10 am
by JamesDuignan
Hi Kazu,

What the customer should use is the visualisation of the field they want to use this will be a class called .editfield, used for alpha/char/string/Numeric etc, Spineditfield can be used for numeric fields and dropdownfields for fields with dropdown lists.

These are the material design visualisations for a reposistory field and therefore contain the definitions the customer is after.

By default dragging a field onto a webpage, view, dialog or a reusable part for the web will use the editfield or dropdownfield visualisations.

here is an example below.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)

Define_Com Class(#STD_ALPHA.EditField) Name(#STD_ALPHA) Displayposition(1) Left(24) Parent(#COM_OWNER) Tabposition(1) Top(30)
Define_Com Class(#STD_DESCS.EditField) Name(#STD_DESCS) Displayposition(2) Left(25) Parent(#COM_OWNER) Tabposition(2) Top(125)
Define_Com Class(#STD_IDNOS.EditField) Name(#STD_IDNOS) Displayposition(3) Left(25) Parent(#COM_OWNER) Tabposition(3) Top(192)
Define_Com Class(#STD_NUM.SpinEditField) Name(#STD_NUM) Displayposition(4) Left(24) Parent(#COM_OWNER) Tabposition(4) Top(280)


End_Com

regards,
James Duignan

Re: Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Tue Jul 31, 2018 3:51 pm
by Kazunori Kasahara
Hi James,

Thank you for your reply.

The customer would like to dynamically change length and allowed characters of the same field on their VL Web program.
EditField statically defines length and allowed characters based on the field definition, so they don't use EditField and are trying to use PRIM_MD.Edit.

They have been developing application package. They would like to change the length and allowed characters of the same field depending on companies who use the package. They would not like to develop and maintain multi VL Web programs for each companies. They would like to have same one VL Web program and support all companies. This is the background that they would like to dynamically control length and allowed characters.

I would appreciate any ideas.

Best regards,
Kazunori Kasahara

Re: Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Tue Jul 31, 2018 4:40 pm
by JamesDuignan
Hi Kazu,

Seeing as they are dynamically changing the dataclass to be different fields why not dynamically create and destroy the editfield visualisations based on the which customer is using the application? This seems like the most logical way to go about this as the data class is using repository defined fields in the first place.

Alternatively you could use the keypress event to monitor the input and length of an edit, using your own rules to define whether data can be entered and the maximum length. See example below.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)


Define_Com Class(#prim_md.Edit) Name(#ThisEdit) Parent(#COM_OWNER) Displayposition(1) Tabposition(1) Width(439) Caption('Enter Data')
Define_Com Class(#PRIM_MD.RadioButton) Name(#CustA) Caption('Customer A  Character A to J byte length 10') Displayposition(2) Left(48) Parent(#COM_OWNER) Tabposition(2) Top(120) Width(409)
Define_Com Class(#PRIM_MD.RadioButton) Name(#CustB) Caption('Customer B - numeric only byte length 5') Displayposition(4) Left(48) Parent(#COM_OWNER) Tabposition(4) Top(160) Width(329)
Define_Com Class(#Prim_str) Name(#AllowedCharacters)
Define_Com Class(#Prim_NMbr) Name(#Allowedlength)
Define_Com Class(#PRIM_MD.RadioButton) Name(#CustC) Caption('Customer C - A to Z, numeric, spaces  & special characters byte length 100') Checked(True) Displayposition(3) Left(48) Parent(#COM_OWNER) Tabposition(3) Top(192) Width(593)


Evtroutine Handling(#COM_OWNER.Initialize)

#CustA.Checked := True

#AllowedCharacters := "ABCDEFGHIJ"

#Allowedlength := 10

Endroutine

Evtroutine Handling(#CustA.Changed)

#ThisEdit := ""

If (#CustA.Checked)

#AllowedCharacters := "ABCDEFGHIJ"

#Allowedlength := 10

Endif

Endroutine


Evtroutine Handling(#CustB.Changed)
#ThisEdit := ""

If (#CustB.Checked)

#AllowedCharacters := "0123456789"

#Allowedlength := 5

Endif

Endroutine

Evtroutine Handling(#CustC.Changed)
#ThisEdit := ""

If (#CustC.Checked)

#AllowedCharacters := "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`~!@#$%^&*()_-+={[}]|\:;?/>.<,'"

#Allowedlength := 100

Endif

Endroutine


Evtroutine Handling(#ThisEdit.KeyPress) Char(#CHAR) Handled(#Handled) Keycode(#Keycode)

If ((#AllowedCharacters.UpperCase.Contains( #CHAR.UpperCase )) *And (#ThisEdit.Value.CurSize < #Allowedlength))

#Handled := False

Else

If (#Keycode <> ISCHAR)

#Handled := False

Else

#Handled := True

Endif

Endif

Endroutine

End_Com

Re: Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Tue Jul 31, 2018 6:12 pm
by Kazunori Kasahara
Thank you very much, James.
I will suggest two options to the customer.
1. Dynamically create and destroy EditField
2. Check logic in the KeyPress event

Re: Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Wed Aug 01, 2018 3:57 pm
by soa
James

How would you dynamically create and destroy an Editfield. Is this then associated with the PRIM_MD.Edit field?

Character by character filtering is fine on the web but if the application is running on a mobile device you want the correct keyboard to pop-up. ie if a field should be numeric then you don't want the full alpha keyboard popping up,

Re: Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Thu Aug 02, 2018 10:24 am
by JamesDuignan
Hi Jim,
How would you dynamically create and destroy an Editfield. Is this then associated with the PRIM_MD.Edit field?
This is nothing special to MD fields, it is like any other dynamically referenced LANSA objects. This is just a suggestion of how they can achieve using different rulesets and definitions for md fields.
Character by character filtering is fine on the web but if the application is running on a mobile device you want the correct keyboard to pop-up. ie if a field should be numeric then you don't want the full alpha keyboard popping up,
The use of numeric input in the example was simply to add contrast to the alpha input, not to say this is how you make it numeric only.

Regards,
James Duignan

Re: Control allowed characters (DBCS/SBCS) for PRIM_MD.Edit field

Posted: Thu Aug 02, 2018 11:37 am
by JamesDuignan
Hi Jim and Kazu,

Here is an example to dynamically create the MD input field to be dynamically created of the visualisation of a repository field.
Basically you need to use the PRIM_MD.Input, this is the base class for MD editfield, spineditfield and DropdownField.
From there you simply assign the field as you need it.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>) Layoutmanager(#LayoutMain)

Define_Com Class(#PRIM_TBLO) Name(#LayoutMain)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutMainColumn1) Displayposition(1) Parent(#LayoutMain) Width(126) Units(Pixels)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutMainColumn2) Displayposition(2) Parent(#LayoutMain) Width(1.79)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutMainRow1) Displayposition(1) Parent(#LayoutMain)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutMainItem2) Alignment(TopCenter) Column(#LayoutMainColumn1) Manage(#MakeInputFieldNum) Parent(#LayoutMain) Row(#LayoutMainRow1) Sizing(None) Flow(Down) Marginbottom(3) Marginleft(3) Marginright(3) Margintop(3)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutMainItem3) Alignment(TopCenter) Column(#LayoutMainColumn1) Manage(#MakeInputFieldAlpha) Parent(#LayoutMain) Row(#LayoutMainRow1) Sizing(None) Flow(Down) Marginbottom(3) Marginleft(3) Marginright(3) Margintop(3)
* Layout Item to be used for MD input field
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutitemInput) Parent(#LayoutMain) Column(#LayoutMainColumn2) Row(#LayoutMainRow1) Sizing(FitToWidth) Margintop(8) Marginright(8) Marginleft(8) Flow(Down) Alignment(TopCenter)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutMainItem1) Alignment(TopCenter) Column(#LayoutMainColumn1) Manage(#MakeSpinEditFieldNum) Parent(#LayoutMain) Row(#LayoutMainRow1) Sizing(None) Flow(Down) Marginbottom(3) Marginleft(3) Marginright(3) Margintop(3)


Define_Com Class(#PRIM_MD.RaisedButton) Name(#MakeInputFieldAlpha) Caption('Give Me an Alpha Field') Displayposition(1) Left(13) Parent(#COM_OWNER) Tabposition(1) Themedrawstyle('MediumTitle') Top(3) Height(62) Wordwrap(True)
Define_Com Class(#PRIM_MD.RaisedButton) Name(#MakeInputFieldNum) Caption('Give Me a Numeric Field') Displayposition(2) Left(13) Parent(#COM_OWNER) Tabposition(3) Themedrawstyle('MediumTitle') Top(71) Height(68) Wordwrap(True)
* Base Class for MD input fields
Define_Com Class(#prim_md.Input) Name(#InputField) Reference(*DYNAMIC)
Define_Com Class(#PRIM_MD.RaisedButton) Name(#MakeSpinEditFieldNum) Caption('Give Me a Spinedit Numeric Field') Displayposition(3) Left(13) Parent(#COM_OWNER) Tabposition(2) Themedrawstyle('MediumTitle') Top(145) Height(68) Wordwrap(True)


Evtroutine Handling(#MakeInputFieldAlpha.Click)
Define_Com Class(#xDemoAlpha128.EditField) Name(#AlphaField)

* Assign the input field reference to the alpha field defined above

#InputField <= #AlphaField

* Make sutre it is parented

#InputField.Parent <= #COM_OWNER

#COM_OWNER.AddtoLayout


Endroutine

Evtroutine Handling(#MakeInputFieldNum.Click)
Define_Com Class(#xDemoNumber.EditField) Name(#NumericField)

* Assign the input field reference to the numeric field defined above

#InputField <= #NumericField

* Make sutre it is parented

#InputField.Parent <= #COM_OWNER

#COM_OWNER.AddtoLayout

Endroutine


Mthroutine Name(AddtoLayout)
* Make the layout managed
#LayoutitemInput.Manage <= #InputField
#LayoutitemInput.Sizing := FitToWidth

Endroutine

Evtroutine Handling(#MakeSpinEditFieldNum.Click)
Define_Com Class(#xDemoNumber.SpinEditField) Name(#NumericField)

* Assign the input field reference to the numeric field defined above

#InputField <= #NumericField

* Make sutre it is parented

#InputField.Parent <= #COM_OWNER

#COM_OWNER.AddtoLayout

Endroutine
End_Com
Regards,
James Duignan