Input/Format Mask

We need to put an input mask on a character field that will include delimiters in the returned data. For example, we have an account mask that would format like this: A234-11-1145. When we enter the text, we would like to show placeholders for the characters (or numbers) and the dashes. The user would type A234111145, but as they enter the text, the placeholders would overwrite with the entered values and automatically skip over the dashes. The actual data in the dataprovider will include the dashes. Here is the kicker: can we assign this input mask at runtime from a method?

Lenore :

  1. To define the format at execution time you can set the FORMAT property of the element, i.e. :

forms.alta_viajes.elements.cliente_id1.format=“A###-##-####”

  1. But you also need that what the user types is not what you store in the database, so you will have to do the conversion by yourself in a method; you should evaluate to use the Conversion feature at table level for the data provider.

dont think lenore has to do conversion because the dashes are coming into the actual data.
and that is the default when you do this “A###-##-####”
You can tell servoy to really store the raw value so A234111145 instead of A234-11-1145
then a mask like this should be fine: “A###-##-####|raw”

Is it possible to set this formatting using an i18n key? I know I can use i18n.setI18NMessage(i18nKey, value) at the start of the session. If I could set the i18n key to the desired format, then I would not have to set every account field in our application at the form level. We have over 200 situations where the field is displayed on a form. That’s a lot of coding. I would like to find a more global way to handle this.

Since the data includes the dashes, the format is fine. The issue is actually the edit format. This is what I would like to set when the application session starts.

Lenore:
Is it possible to set this formatting using an i18n key?

This is indeed possible, just enter ‘i18n:[KEY]’ into the format field.
Using i18n.setI18NMessage(i18nKey, value) is a great way to globalize this…

We use this the exact same way every day.

I tried applying this format and ran into a problem. The account field I am trying to apply this to is a character field so I do not get an edit format. I think I’m back to square one :|

first if you have 1 column in the db that you use all over the place and there you want a format on
Set the format in the column properties… Then they will be used everywhere.

Text columns currently dont have edit/display formats .
They only have edit format with a placeholder character or string what needs to be displayed if there is no char on that position yet.
(like dd-mm-yyyy for a textual date field)