Dates in text fields

Questions and answers for designing and implementing forms in Servoy

Dates in text fields

Postby maria » Tue Nov 03, 2009 3:25 am

Hi,

I have a bunch of problems concerning my dates in the text fields and was wondering if anyone can help me find a good way out.

1. The field must have a mask (display ' / / ') and only allow integers. Well, that's sorted out. The problem was putting a mask and format together on a field that has a dataprovider of type timestamp. Creating a text var and putting it as the dataprovider works well, though requires some programming and using naming conventions for date fields. It would be great in Servoy has a separate property for format and mask.

2. The double-click on the date field should put the today's date in it. The users love this feature and they want it.
Currently we put an icon next to the field that will perform the same functionality.
However, the double-click on a field would be highly desirable in the next release of Servoy.
Generally, different types of elements should support all kinds of events on them because it might be frustrating having a double-click on a label but not being able to set the format for it, or on the contrary - being able to format a text field without the ability of a double-click.
Could the Servoy developers, please, comment on this?

3. The users also love to change the date to next or previous by hitting '+' or '-' on the keyboard while the focus is in the date field.
This obviously requires a key listener which is implementable with a JTextField bean.
But again, we can't put a mask on a JTextField, after all we'd like to leave alone the beans for this purpose.
Is there any other solution to this problem that I don't see? (except adding the buttons to go to the next/previous date)

Thanks,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Dates in text fields

Postby IT2Be » Tue Nov 03, 2009 3:49 pm

maria wrote:Hi,

I have a bunch of problems concerning my dates in the text fields and was wondering if anyone can help me find a good way out.

1. The field must have a mask (display ' / / ') and only allow integers. Well, that's sorted out. The problem was putting a mask and format together on a field that has a dataprovider of type timestamp. Creating a text var and putting it as the dataprovider works well, though requires some programming and using naming conventions for date fields. It would be great in Servoy has a separate property for format and mask.
But you can do this already, there is the format property of a dataprovider field. Are you using the Calendar type for the field?

maria wrote:2. The double-click on the date field should put the today's date in it. The users love this feature and they want it.
Currently we put an icon next to the field that will perform the same functionality.
However, the double-click on a field would be highly desirable in the next release of Servoy.
Generally, different types of elements should support all kinds of events on them because it might be frustrating having a double-click on a label but not being able to set the format for it, or on the contrary - being able to format a text field without the ability of a double-click.
Could the Servoy developers, please, comment on this?
I don't like this suggestion.

maria wrote:3. The users also love to change the date to next or previous by hitting '+' or '-' on the keyboard while the focus is in the date field.
This obviously requires a key listener which is implementable with a JTextField bean.
But again, we can't put a mask on a JTextField, after all we'd like to leave alone the beans for this purpose.
Is there any other solution to this problem that I don't see? (except adding the buttons to go to the next/previous date)
If I am correct you can (still) use arrow up and down to go up and down in a date. BTW you talk about a JTextField. When you really use the Java TextField (not the predefined Servoy textfield) you can add a listener yourself without much work. Just check the internet for that. I even believe that there are one or more samples in this forum about using listeners.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re: Dates input (maybe in text fields...)

Postby gianni » Wed Nov 04, 2009 11:11 am

Maria,

some toughts/suggestions on your points:
1. As Marcel already told, first of all, it is better to use a calendar field to manage dates input and remember to define a global date format or a specific date format to adapt it to your needs.
3. As Marcel already told, the functionality you ask for is already there but you MUST use a calendar field to have it; when you are in a calendar field and position your input on days or months or year, you can change the value with up or down arrow.
2. Dates input: I fully agree with you some improvements should be done into Servoy. I've done a proposal few days ago in this forum; you can read it here: viewtopic.php?f=13&t=13201. Pls take some time to add your comments.

Ciao,
Gianni
gianni
 
Posts: 64
Joined: Sat Feb 12, 2005 2:26 pm
Location: Vercelli, Italy

Re: Dates input (maybe in text fields...)

Postby maria » Thu Nov 05, 2009 12:14 am

Guys,

How about a mask like this ' / / ' ?
I know I can format a field but I need a mask with the slashes to separate months, days and years.
It's impossible to have them on a timestamp field of type calendar I guess.
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Dates in text fields

Postby maria » Thu Nov 05, 2009 12:25 am

IT2Be wrote:
maria wrote:2. The double-click on the date field should put the today's date in it. The users love this feature and they want it.
Currently we put an icon next to the field that will perform the same functionality.
However, the double-click on a field would be highly desirable in the next release of Servoy.
Generally, different types of elements should support all kinds of events on them because it might be frustrating having a double-click on a label but not being able to set the format for it, or on the contrary - being able to format a text field without the ability of a double-click.
Could the Servoy developers, please, comment on this?
I don't like this suggestion.

Well, the users do like it, Marcel.

maria wrote:3. The users also love to change the date to next or previous by hitting '+' or '-' on the keyboard while the focus is in the date field.
This obviously requires a key listener which is implementable with a JTextField bean.
But again, we can't put a mask on a JTextField, after all we'd like to leave alone the beans for this purpose.
Is there any other solution to this problem that I don't see? (except adding the buttons to go to the next/previous date)
If I am correct you can (still) use arrow up and down to go up and down in a date. BTW you talk about a JTextField. When you really use the Java TextField (not the predefined Servoy textfield) you can add a listener yourself without much work. Just check the internet for that. I even believe that there are one or more samples in this forum about using listeners.[/quote]

Yes, I'm already using listeners on JTextFields but I can't put a mask on that kind of field because I need a JFormattedTextField.
Thanks Marcel.
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Dates input (maybe in text fields...)

Postby maria » Thu Nov 05, 2009 12:42 am

gianni wrote:Maria,

some toughts/suggestions on your points:
1. As Marcel already told, first of all, it is better to use a calendar field to manage dates input and remember to define a global date format or a specific date format to adapt it to your needs.
3. As Marcel already told, the functionality you ask for is already there but you MUST use a calendar field to have it; when you are in a calendar field and position your input on days or months or year, you can change the value with up or down arrow.
2. Dates input: I fully agree with you some improvements should be done into Servoy. I've done a proposal few days ago in this forum; you can read it here: viewtopic.php?f=13&t=13201. Pls take some time to add your comments.

Ciao,
Gianni


Thanks Gianni,
I posted some comments in your topic.

So far I might have made myself unclear on the topic of masks because the guys just send me back to calendar fields that can't implement what I need.
I want a visible mask in the field and I don't want the user to have to type the slashes (or whatever other separators are there).
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Dates in text fields

Postby IT2Be » Thu Nov 05, 2009 12:45 am

There is always the possibility to build all that you want yourself by creating a bean.

When I say 'I don't like this', I am a user as well.
Some things are possible some are not (out of the box).
What you want, if not possible as an option for instance, is contrary to what many user are already used to.
That is why I said that I don't like it.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re: Dates in text fields

Postby maria » Thu Nov 05, 2009 4:57 am

IT2Be wrote:There is always the possibility to build all that you want yourself by creating a bean.

When I say 'I don't like this', I am a user as well.
Some things are possible some are not (out of the box).
What you want, if not possible as an option for instance, is contrary to what many user are already used to.
That is why I said that I don't like it.


Sorry, I failed to specify that our users like it.
They have been using our application for ages and we re-write it in Servoy, so they already have that double-click and I'll have to develop a bean to implement all I want (all they want). Though I still think that having the same events on all form elements does make sense and broadens the programmer's capabilities.
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Dates in text fields

Postby ROCLASI » Thu Nov 05, 2009 2:14 pm

Hi Maria,

maria wrote:1. The field must have a mask (display ' / / ') and only allow integers. Well, that's sorted out. The problem was putting a mask and format together on a field that has a dataprovider of type timestamp. Creating a text var and putting it as the dataprovider works well, though requires some programming and using naming conventions for date fields. It would be great in Servoy has a separate property for format and mask.

You could use a global method that you put on the onDataChange event that takes the inserted data and transforms it into the right format.
You might even take a look at the mod_datejs module from Greg Pierce to make it easier for you to write the code.

maria wrote:2. The double-click on the date field should put the today's date in it. The users love this feature and they want it.
Currently we put an icon next to the field that will perform the same functionality.
However, the double-click on a field would be highly desirable in the next release of Servoy.
Generally, different types of elements should support all kinds of events on them because it might be frustrating having a double-click on a label but not being able to set the format for it, or on the contrary - being able to format a text field without the ability of a double-click.
Could the Servoy developers, please, comment on this?

Fields don't have onClick or onDoubleClick events but you can use the onRightClick event to show a menu with options or to put the current date in the field right away.

maria wrote:3. The users also love to change the date to next or previous by hitting '+' or '-' on the keyboard while the focus is in the date field.
This obviously requires a key listener which is implementable with a JTextField bean.
But again, we can't put a mask on a JTextField, after all we'd like to leave alone the beans for this purpose.
Is there any other solution to this problem that I don't see? (except adding the buttons to go to the next/previous date)

I think you can do this in Servoy 5 using the 'Window' plugin (where you can set/remove shortcuts ON THE FLY).
So you could register - and + when the field gets the focus and remove the shortcuts again when the field loses it's focus.

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Dates in text fields

Postby jcompagner » Mon Dec 07, 2009 5:41 pm

i am currently looking if i can introduce a mask for date fields. (in 5.1)
You will have to specify it like : dd/MM/yyyy|MASK

because dates are a bit tricky this for example: d/M/yy is a valid date format that will parse 23-2-2009 just fine
but as you can see a user can type more then the format itself says because the single d stands for 2 digits..

So if i can make this work nicely it really only works for the exact mask..
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Dates in text fields

Postby maria » Wed Dec 09, 2009 5:15 am

jcompagner wrote:i am currently looking if i can introduce a mask for date fields. (in 5.1)
You will have to specify it like : dd/MM/yyyy|MASK

because dates are a bit tricky this for example: d/M/yy is a valid date format that will parse 23-2-2009 just fine
but as you can see a user can type more then the format itself says because the single d stands for 2 digits..

So if i can make this work nicely it really only works for the exact mask..


That's very nice of you Johan.
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney


Return to Forms

Who is online

Users browsing this forum: No registered users and 7 guests