How do I set a value in a CALENDAR field by code?
I want for example, that when a User creates a new Record, that the date is already set to 01.01.2011 as a suggestion.
I tried something like this, whit no luck.
var _date = new Date()
var _year = _ date.getFullYear()
var _from = new Date(_jahr, 0, 1)
var _until = new Date(_jahr, 11, 31)
elements.dp_from = _from
elements.dp_until = _until
I got this error:
Exception Object: java.lang.RuntimeException: Can’t put in a locked scope, name: dp_from, value: org.mozilla.javascript.NativeDate@2c3ca7aa
MSG: Can’t put in a locked scope, name: dp_from, value: org.mozilla.javascript.NativeDate@2c3ca7aa
Can’t put in a locked scope, name: dp_from, value: org.mozilla.javascript.NativeDate@2c3ca7aa
Wrapped java.lang.RuntimeException: Can’t put in a locked scope, name: dp_from, value: org.mozilla.javascript.NativeDate@2c3ca7aa
The dataprovider is on the Database and I don’t want to edit this value, I just want to give the user a suggestion.
I don’t want to set the value on the Database.
the only thing you can do is set it on the record object but not save it.
But yes if it then saves it at a later point the suggestions are saved (or you somehow need to track this and revert)
You can’t otherwise set suggestions, the shown in the field is the records data that is in memory.
jcompagner:
the only thing you can do is set it on the record object but not save it.
But yes if it then saves it at a later point the suggestions are saved (or you somehow need to track this and revert)
You can’t otherwise set suggestions, the shown in the field is the records data that is in memory.
Sounds to me like a great idea for a suggestion property on text field elements
The suggestion would be a display only value then, not something that is stored into the database.
Expected behaviours could be:
At OnFocus the suggestion disappears
At OnFocusLost and when no value is entered, the suggestion appears again
Properties could be:
Suggestion (with i18n support)
Suggestion textcolor
problem is that this is not directly nice supported by the swing text fields (or html for web) themselfs
so we need to build that that the suggestion is some kind of layer over the real input. Thats can become quite a bit of work…
Thanks for your help, I found now a way.
I add the default value to the new record which is created.
When the user doesn’t change the default value, this will be saved on the database.
If the user cancels the record will not be added to the database anyway.
That’s ok for me, I just have to be sure that I present the right default value.
ttmgybta:
Thanks for your help, I found now a way.
I add the default value to the new record which is created.
When the user doesn’t change the default value, this will be saved on the database.
If the user cancels the record will not be added to the database anyway.
That’s ok for me, I just have to be sure that I present the right default value.
Right. I assume you’re not using i18n for your suggestion values then?
No, it is a date on a CALENDAR field.
So I don’t know what kind of i18n value I could use in a CALENDAR field.
But I think when it is a text field, it would be possible to use an i18n value as suggestion.