On 6/21/05, Brian Moseley <[EMAIL PROTECTED]> wrote:
>
> i'm using this code to define a property:
>
> InternalValue[] defaultValues1 = {
> InternalValue.create(Calendar.getInstance())
> };
>
> PropDefImpl createdDef = new PropDefImpl();
> createdDef.setName(new QName(URI_TICKET, "created"));
> createdDef.setRequiredType(PropertyType.DATE);
> createdDef.setAutoCreated(true);
> createdDef.setDefaultValues(defaultValues1);
> createdDef.setMandatory(true);
> createdDef.setOnParentVersion(OnParentVersionAction.INITIALIZE);
> createdDef.setProtected(true);
> createdDef.setMultiple(false);
> createdDef.setDeclaringNodeType(ticketDef.getName());
>
> with this code, the declaring node type definition successfully registers.
>
> however, looking at custom_nodetypes.xml, the default value is being set
> to the moment in time that i execute the above code to register the node
> type ("<defaultValue>2005-06-20T17:43:47.364-07:00</defaultValue>").
> this makes a kind of sense, but it's not what i want.
>
> how can i define the property such that the property's value is set to
> the time when the node is created, not when the node type is registered?
dynamic default values are not yet supported. there are some related
inline @todo comments. see
BatchedItemOperations#computeSystemGeneratedPropertyValues
and NodeImpl#computeSystemGeneratedPropertyValues.
what i have in mind is a NodeTypeInstanceHandler callback interface
that can be registered for a specific node type. there are several
open questions/problems though, e.g. portability, xml format of a
node type with dynamic default values, dynamic values that depend
on other values, method signatures of the callbck interface etc etc
however it's on my todo list.
> this is exactly how jcr:created behaves, isn't it?
the behaviour of jcr:created is spec'ed in jsr 170 and is hardcoded in
jackrabbit. once we have a clean way of declaring/applying dynamic
default values i'll replace that code with a generic solution.
cheers
stefan
>