setValueListItems stucks

I have a datetime field formatted as HH:mm.
If I set it from a custom valuelist values like

08:00
08:15
08:30
08:45
09:00

it works fine.

If I set the valuelist from an array:

application.setValueListItems( ‘ore2’, new Array(‘08:00’,‘08:15’,‘08:30’))

the list appears as expected but if I choose a value Servoy stucks with this simple error: java.lang.String, and I have to close it with Task Manager, no other way.
Probably the array handles a wrong kind of data, but how to set it properly?

That’s probably because your custom value list delivers Strings and not datetimes.

patrick:
That’s probably because your custom value list delivers Strings and not datetimes.

The valuelist with Custom Values… works fine, but same values into an array freeze Servoy.
What is the difference?

lcr159:
The valuelist with Custom Values… works fine, but same values into an array freeze Servoy.
What is the difference?

Since you can only add text in the value list editor Servoy will probably cast it accordingly to the field type.
When using the setValueListItems() function Servoy expects that you do the casting.
In other words, make them Date objects instead of strings.

ROCLASI:
Since you can only add text in the value list editor Servoy will probably cast it accordingly to the field type.
When using the setValueListItems() function Servoy expects that you do the casting.
In other words, make them Date objects instead of strings.

Ok, but how?

There are several ways to create Date objects.
In the Servoy Editor you find under the JS Lib node a Date node.
It shows all the date functions.
For example:

var date = new Date(year, month, day, hours, minutes, seconds);

Using this example we can make a value list like so:

var dArray = [new Date(2006,1,1,8,0,0),new Date(2006,1,1,8,15,0),new Date(2006,1,1,8,30,0),new Date(2006,1,1,8,45,0),new Date(2006,1,1,9,00,0)];

//application.setValueListItems( name,  display_val_array/dataset,  [real_values_array])
application.setValueListItems( 'ore2', ['08:00','08:15','08:30','08:45','09:00'], dArray);

Hope this helps.

Thanks, I tried this:

arrayOre1 = new Array(‘08:00’,‘08:15’,‘08:30’,‘08:45’,‘09:00’);

arrayOre2 = new Array(new Date(1970, 00, 00, 8, 0, 0),
new Date(1970, 00, 00, 8, 15, 0),
new Date(1970, 00, 00, 8, 30, 0),
new Date(1970, 00, 00, 8, 45, 0),
new Date(1970, 00, 00, 9, 0, 0));

application.setValueListItems(‘ore’,arrayOre1,arrayOre2)

but I got the same error java.lang.String and task manager to leave, as before.

What happens when you leave out the dates? Does that work like you expect it to work?

Have you tested that? If not, can you test that?