[daisy] Programmatically create a link (VariantKey)

Robert Cecil rob.cecil at gmail.com
Tue Dec 5 08:31:50 CST 2006


Awesome help guys. I had stumbled onto the bare constructor, and  
frankly, I was unsure of myself. I was unsure because my previous  
experience with the API seemed to follow more of factory-method  
approach for lifecycle (createDocument(), etc, etc.)

Have you thought about making a factory method on VariantManager or  
DocumentManager called

createDefaultVariant(Document doc)


On Dec 5, 2006, at 4:19 AM, Bruno Dumon wrote:

>
> Just some more information:
>
> A VariantKey instance can be created simply using "new",
> i.e. new VariantKey(documentId, branchId, languageId)
>
> The branchId and languageId in the VariantKey object can be set to the
> value -1, which means the branch and language should default to the
> branch and language of the document containing the link.
>
> This is useful if you're ever going to use document variants. When
> duplicating an existing variant into a new variant, the branch and
> language of the link in the link-type field will then automatically
> adjust to the branch and language of the new variant, otherwise they
> would point to some fixed branch and language.
>
> So to summarize, the recommended way to set a link field would be:
>
> document.setField("linkfield", new VariantKey 
> (linkTargetDocument.getId(), -1, -1));
>
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno at outerthought.org                          bruno at apache.org
>
> _______________________________________________
> daisy community mailing list
> Professional Daisy support: http://outerthought.org/site/services/ 
> daisy/daisysupport.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cocoondev.org/pipermail/daisy/attachments/20061205/f8960469/attachment.htm


More information about the daisy mailing list