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 !
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.
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.
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.
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)
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