kevink responded: |
2010-07-06 15:36 |
The validation script should be named:
/queries/<schema>/<query>.js
so for your example the file should be "/queries/study/arrival.js" |
|
Ben Bimber responded: |
2010-07-06 15:51 |
should have seen that - thanks. one more question:
i have this line to provide a default for the timestamp (ts) field:
row.ts = new Date().format("Y-m-d");
that would normally work, but it throwing an error in the validation script. error below:
500: Unexpected server error
com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: TypeError: Cannot find function format in object Tue Jul 06 2010 17:49:37 GMT-0500 (CDT). (queries/study/Arrival.js#56) in queries/study/Arrival.js at line number 56
Is there a reason why that would throw an error?
thanks. |
|
kevink responded: |
2010-07-06 16:12 |
The format method is an Ext extension to the Date prototype not available in the server side environment. It would be nice to support the ext core extensions on the server side. Here is a list of available methods:
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Date
If the column type is a Date type you should be able to just use "new Date()" instead of creating a string first. |
|
Ben Bimber responded: |
2010-07-06 16:20 |
that makes sense. i didnt realize format() was ext.
I originally tried:
row.ts = new Date();
however, that resulted in this error:
Could not convert 'org.mozilla.javascript.NativeDate@1321992' for field ts, should be of type Date
That's why i started trying to make a string. Does that error make sense? |
|
kevink responded: |
2010-07-06 16:24 |
Ok, for now you can use "new java.util.Date()" instead. |
|
Ben Bimber responded: |
2010-07-06 16:25 |
thanks. |
|
Ben Bimber responded: |
2010-07-08 14:53 |
if i want to print a date as a string in the description field, is there an easy way to format it as 'yyyy-mm-dd' instead of the default long date string? below is the closest i came, but it seems like it should be simpler:
dateString: function (date){
date = new Date(date);
return date.getFullYear()+'-'+(date.getMonth()<10 ? 0:'')+date.getMonth()+'-'+(date.getDate()<10 ? 0:'')+date.getDate();
} |
|
kevink responded: |
2010-07-08 15:59 |
There isn't any built-in Date formatting so your function is the best way to get the string you want. |
|