How do I force uppercase?

This seems like a silly question but I can’t figure out how to force uppercase on a field ?

I tried setting the ‘format’ property of the field to ‘|U’ in the designer but that didn’t change anything when I ran the form.
I also tried setting the ‘format’ property to UUUUUUUUUUUUU but that didn’t change anything either.

Is there any way to quickly force entry to uppercase ? Help !

Thanks in advance
Mark

One approach, use onFocusLost method:

myfield = myfield.toUpperCase();

Dean Westover
Choices Software, Inc.

markhooper:
I tried setting the ‘format’ property of the field to ‘|U’ in the designer

That is the way to go, but your field has to be a TEXT_FIELD. Otherwise you should use a method on the onFocusLost, onDataChange or table event, like Dean suggested.

Thanks for the replies.

I would like to pursue the onFocusLost() technique as I think this could work.

I would like to have the onFocusLost() call a global method and then have that global method determine the form.field that was just left and then perform the toUpperCase on that form.field - is there a way to do this?

EDIT… I believe I can use the application.getMethodTriggerElementName()

Well, I’ve got something that works based on the ‘onFocusLost’ event.

This works fine for data entry but not for ‘find’ mode - as soon as I place my form in ‘find’ mode, key in a value then move to another field the method associated with the ‘onFocusLost’ doesn’t fire.

Thoughts?

EDIT… I’ve got fields that are TEXT_FIELD types that I set the format to |U - when I run the form and key something into these fields the case remains lower. What am I doing wrong ? I’m using Servoy v4.1.0 and creating a web-client application.

EDIT EDIT … specifying ‘|U’ as the format works only in smart client :( We need this to work in web-client.

Hi Mark,

Find mode disables methods/events from being run for a reason.
You wouldn’t want your users executing any business logic while in find mode.

If you are trying to do a case-INsensitive search, then you can prefix your search criteria w/ a ‘#’ symbol.
Obviously you would have to do this programmatically if you want to hide this from the user.

hope this helps.

Hi Sean, thx for your reply and I can appreciate not wanting to execute business logic while in find - that makes sense.
However, there appears to be a bug with the way the web client handles the ‘format’ that I gave it.
Specifying |U as the format is respected in the smart-client but not in web-client. Is there any workaround for this ?

best thing for this to do (and this will always also be the savest way) if you want upper case in the database is to do this with a converter

You can attach on a column a global method converter and in the to and from you attach methods that do the to upper case conversion (from) the to can just return the input. (thats from db so thats already ok)

Westy:
One approach, use onFocusLost method:

myfield = myfield.toUpperCase();

Dean Westover
Choices Software, Inc.

I do the same, but not in onFocusLost but in a database trigger (onInsert & onUpdate)
Perhaps the input is not directly converted to uppercase after input, but you are sure that from whatever form you use this field, it is always converted to uppercase before being written to the database

with a database trigger you have to requery the stuff in servoy else servoy never will see that change.
If you use a global converter (or a converter written in java) then it will also make sure that it is always upper case
except that it happens a bit earlier (before the save already) and is pushed to the ui after conversion.

jcompagner:
best thing for this to do (and this will always also be the savest way) if you want upper case in the database is to do this with a converter

You can attach on a column a global method converter and in the to and from you attach methods that do the to upper case conversion (from) the to can just return the input. (thats from db so thats already ok)

I got it work, but why so difficult?

In the dataprovider tab “Conversion” I had to add the globals.toUpperCase() method to both fromObjectMethodName and toObjectMethodName
For me it is not clear why I have to use both from and to. But when using only one of them, then it is not working

And Servoy documention is also not clear about it

yes this is a bug that is already fixed (in 4.1.4)

You have to specify both (dont have to be the same method, 1 cant just be “return arguments[0]”) in 4.1.3

In 4.2 we improved the validators/converters editors so it is way easier to configure

jcompagner:
yes this is a bug that is already fixed (in 4.1.4)

You have to specify both (dont have to be the same method, 1 cant just be “return arguments[0]”) in 4.1.3

In 4.2 we improved the validators/converters editors so it is way easier to configure

How should it be used in 4.1.4? Using the FromObjectMethod or the ToObjectMethod?

in 4.1.4 if you just want to convert all the values that go to the database to upper case you just have to
specify the fromObjectMethod

in 4.2 this will be displayed to you as

“Global method to convert Object to DBValue, signature: (object,columntype)”

and the toObjectMethod will be be displayed as:

“Global method to convert DBValue to Object, signature: (dbvalue,columntype)”

OK, now it is clear to me what the fromObject en toObject mean, because it was not clear.