[daisy] Help setting multivalue link field
Derek Coffman
Derek.Coffman at noaa.gov
Mon Jan 21 01:53:24 CST 2008
Hi,
I am writing an "wizard" type extension to allow users to create and
"InstrumentDefinition" document. The document contains a multivalue link
field of "InstrumentTypes" (i.e., a list of documents of type
"InstrumentType"). In the wizard, the user is presented with a
double-listbox multivalue field and required to select at least one
type. The types are show as the name of the InstrumentType. Once the
user submits the completed form, I am trying to use getValue() of that
widget which should return an array of Strings if I understand
correctly. In order to set the multivalue link field, I need to turn
those names into an array of VariantKey...correct?
My question: what is the best way to do this in javascript? Here's one
iteration I've tried...
var types = form.getChild("def_inst_types").getValue();
var ids = new Array();
for (i=1; i<types.length; i++) {
var type_str = types[i].toString();
searchresults = queryManager.performQuery("select id where
documentType='InstrumentType' and name='"+type_str+"'",locale.getDefault());
rows =
searchresults.getSearchResult().getRows().getRowArray();
var typeid = rows[0].getValueArray(0);
var typedoc =
daisy.getRepository().getDocument(typeid,false);
ids[i] = typedoc.getVariantKey();
}
var repository2 = daisy.getRepository();
var document = repository2.createDocument(title.toString(),
"InstrumentDefinition");
document.setField("InstrumentTypes",ids);
Am I completely off track here? When I run this, I get an error that says:
Wrapped org.outerj.daisy.repository.DocumentTypeInconsistencyException:
The value for the multivalue-field "InstrumentTypes" should be an array.
(file:/home/web/acglocal/daisy/acgwikidata/sites/cocoon/instrument/instrument.js#566)
The value for the multivalue-field "InstrumentTypes" should be an array.
Thanks for any advice you can give,
Derek
--
_________________________________________________________
Derek Coffman derek.coffman at noaa.gov
NOAA/PMEL phone: 206-526-6574
7600 Sand Point Way NE 206-526-6790
Seattle, WA 98115 fax: 206-526-6744
http://saga.pmel.noaa.gov
_________________________________________________________
More information about the daisy
mailing list