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