How do I force uppercase?

Forum to discuss the Web client version of Servoy.

How do I force uppercase?

Postby markhooper » Mon May 11, 2009 9:25 pm

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
markhooper
 
Posts: 84
Joined: Fri May 30, 2008 7:28 pm
Location: Canada

Re: How do I force uppercase?

Postby Westy » Tue May 12, 2009 12:16 am

One approach, use onFocusLost method:

Code: Select all
myfield = myfield.toUpperCase();

Dean Westover
Choices Software, Inc.
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: How do I force uppercase?

Postby Joas » Tue May 12, 2009 7:01 am

markhooper wrote: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.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: How do I force uppercase?

Postby markhooper » Mon May 25, 2009 5:58 pm

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()
markhooper
 
Posts: 84
Joined: Fri May 30, 2008 7:28 pm
Location: Canada

Re: How do I force uppercase?

Postby markhooper » Mon May 25, 2009 10:57 pm

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.
markhooper
 
Posts: 84
Joined: Fri May 30, 2008 7:28 pm
Location: Canada

Re: How do I force uppercase?

Postby sdevlin » Tue May 26, 2009 6:10 pm

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.
Sean Devlin
Servoy USA
sdevlin
 
Posts: 125
Joined: Tue Apr 13, 2004 3:33 am

Re: How do I force uppercase?

Postby markhooper » Wed May 27, 2009 8:40 pm

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 ?
markhooper
 
Posts: 84
Joined: Fri May 30, 2008 7:28 pm
Location: Canada

Re: How do I force uppercase?

Postby jcompagner » Mon Jun 15, 2009 1:44 pm

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)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8839
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How do I force uppercase?

Postby martinh » Mon Jun 15, 2009 2:08 pm

Westy wrote:One approach, use onFocusLost method:

Code: Select all
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
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: How do I force uppercase?

Postby jcompagner » Mon Jun 15, 2009 2:12 pm

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.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8839
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How do I force uppercase?

Postby martinh » Thu Jun 18, 2009 1:41 pm

jcompagner wrote: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
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: How do I force uppercase?

Postby jcompagner » Thu Jun 18, 2009 2:55 pm

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
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8839
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How do I force uppercase?

Postby martinh » Thu Jun 18, 2009 3:09 pm

jcompagner wrote: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?
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: How do I force uppercase?

Postby jcompagner » Thu Jun 18, 2009 3:17 pm

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)"
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8839
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How do I force uppercase?

Postby martinh » Thu Jun 18, 2009 3:27 pm

OK, now it is clear to me what the fromObject en toObject mean, because it was not clear.
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 3 guests