Pet peeve: Calendar fields and data validation

I filed a case on this a while ago (158143), but need some input to get a workaround.

One of my biggest pet peeves with Servoy is the “CALENDAR” field type, and data entry in general. Date fields are painfully inflexible about data input, difficult for users, and the calendar is ugly – IMHO.

I would like to just put in text fields, and validate/manipulate the results – but that is currently impossible if the field is bound to a “datetime” dataprovider. The field itself is doing validation that occurs before a get a chance to do anything myself. If you enter invalid data in a date field, you get the red text and can’t leave the field, and the table level validators are never fired and the onDataChange event is never fired.

It seems to me, if I have provided a global validator on the column in the data provider, any other validation should be ignored and mine should override.

Same basic issue is true for number fields, I believe, as well.

Right now, the only thing I can think to do is to add a text column for every date column, do the data entry in that, and then update the date field manually in my code…but I’m not to crazy about having to add those columns that serve no other purpose. I can’t just do it with variables, because I need it to work in table views/list views.

Is their any low-level Java trick that I might be able to use to disable the validation, or could the engineering team consider changing this behavior?

Thanks

Servoy to the rescue…

We just discovered ourselves that this feature is undocumented, but since 3.5.x, you can set the format of a field to “converter”. When you do that, the field basically becomes a textfield as far as input is concerned.

Using a globalMethodConverter on the column, you can then convert whatever input your users inputs into the field into a proper value to store in the database.

For example, you can create code that converts the userinput of “+1” in tomorrow’s date.

I think this solves your issue, doesn;t it?

Paul

Yes, this solves my issue! Gack! Wish I had known about this much, much sooner.

Now, while you are rescuing things, could you please rescue the brain cells I’ve burnt on this problem!!!

BTW, with this implemented, I can now fully utilize my mod_datejs module. The date fields work exactly like the sample on the Date.js homepage (http://www.datejs.com/) – you can just type in “today”, “+5 hours”, “next friday” and it’s parsed and converted to a date for you!!! Sweet!!!

Thanks,

greg.

So close to heaven, yet so far away!!!

“converter” format works great in Record and List views – but is broken in TableView. I filed a case (178507) w/ sample solution demonstrating.

greg.

Hi Greg,

Too bad you encountered an issue in tableViews. Tnx for filing the case, I’ll see if this can be addresses shortly.

As for the braincells: sorry, no can do, too busy rescuing my own…

Could you post a sample of how you usitlize the moddate_js with this functionality? i think it would be interesting for the rest of the world to see this.

Paul

Yes, I’ll post a sample – or maybe do another screencast on it.

It’s pretty slick. It would be great if that fix could happen fast, I’ve got an immediate need for this in a really date-heavy solution.

g.

Hi greg,

I do not fully understand how this works,

when I select the column in the dataprovider window and goto tab: conversion, I can’t select a global method, it says only: none.

I’m comming from here:
viewtopic.php?f=3&t=11818#p59232

Where it says “None”, it’s a combobox, right? No other values than none?

If so, I guess you removed some of the plugins that ship with Servoy, like: converters.jar and serialize.jar

Paul

yes ineed, it’s the combox,

the serialize.jar I can find in the plugin folder, but the converts.jar I can’t find anywhere.
And I’m sure I never throw things away.

Should it be also in the plugin folder?

I’m using Servoy 3.5.7

ah, you chose to miss out on all the good stuff by not upgrading? :-)

Well, I think the 3.5 installs also included the cnverters.jar, so if you do not have it, it must have been removed.

Can you check with a clean install?

Hi Paul,

I checked my install of 3.5.7 and I also don’t have converters.jar. Not in /lib nor in /plugins .
And I never throw things away out of these directories.

It seems we never shipped the default converters.jar in 3.5.x, you can manually download:
http://www.servoy.com/downloads/downloa … erters.jar

Will also be included in Servoy 3.5.8

Can someone explain how to use the GlobalMethodConverter? I must be missing something basic, but I don’t know what to put in the Value column next to “fromObjectMethodName” and “toObjectMethodName” I have a method that converts the entered date into what I want it to be. Using servoy 4.1

You put the name of the method there that you have created to do the conversion.

Paul

Thanks Paul, I figured it was something that simple. But if I have only one method that looks at what the data is, manipulates it appropriately and sets the field to the resulting formatted string, do I put that in the from or to value, or both? Or am I not designing my method correctly?

You can use the same method for both values if your method can handle both conversions.

Paul

I am having an issue with date formats also. It seems that when the user enters 09/01/76 it is automatically changed to 09/01/0076 which is unacceptable. I would like to use the date.js to validate the date.

Is the download for the converter jar still valid for Servoy version 4.1.3? I can format the field to converter, but do not have any options to enter the to and from global methods.

A sample of how you solved the date issue would be great!

Is there a worked example of the use of date converters in Servoy? It looks very useful.
On the form, does the field need to be CALENDAR or TEXT_FIELD? If the latter, how to get a calendar to pop up?

Still wondering if there’s a worked example of this available?

Sure there is. Check out the mod_datejs demo app from Greg Pierce.
Also check out the very powerful datejs module he is using with it.

http://code.google.com/p/servoymoddatejs/downloads/list