[OpenAjaxIDE] @default for various data types

Jon Ferraiolo jferrai at us.ibm.com
Thu Aug 7 17:03:48 PDT 2008



As Aaron Reed was implementing the properties parts of the metadata spec in
the reference implementation, he sent these comments:
-------------
On your guys' todo list you should have an item about adding a little more
information into @default on a property.  Like it should be a JSON string
(I assume) for datatypes Array, [type], object, etc.  And maybe give an
example in case an author wants to create a widget with a datatype of
object and give a default value and how quoting will mess it up.  Maybe
better to have default be an element instead of an attribute?
-------------

Here is a strawman proposal to which people can respond:

* Leave it as an attribute (@default) because 99% of the time the default
value will be a simple value (e.g., empty string or zero). Also, remember
that we recently decided that @default on <property> was a required
attribute. It would be ugly if we required a <default> subelement with
every <property>.

* If datatype="String", then the the value of the @default attribute is
treated as a string.

* If datatype="Date", then the the value of the @default attribute is
treated as a string whose value will be parsed by the JavaScript date.parse
() function.

* If datatype is anything else, then the value of the @default attribute
represents a JavaScript expression. As a result:

default="0" ==> a Number
default="true" ==> a Boolean
default="/^.*$/" ==> a RegExp
default="{}" ==> an Object with no properties
default="[]"  ==> an Array with no elements

Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openajax.org/pipermail/ide/attachments/20080807/2e527858/attachment.html 


More information about the IDE mailing list