Login  Register

Does anyone know of a way to get at the labels through the <xforms:select> control?

Posted by mar on Jan 04, 2010; 11:57pm
URL: https://discuss.orbeon.com/Does-anyone-know-of-a-way-to-get-at-the-labels-through-the-xforms-select-control-tp998708.html

Hi all,
 
Does anyone know of a way to get at the labels through the <xforms:select> control?
When a user selects a label or labels the value(s) are stored in the referenced element but not the label(s)
and I need the labels for use as part of the data that will be persisted from the form.
My problem is this, users want to be able to mix <xforms:select> <xforms:itemset>’s from different sources.
Some are hard coded in the form (via instance) while others come from XPL to an instance. I need to be able to
find and return the user selected label(s) after the selection(s) is made. I’m returning the value(s) as the
elements value and trying to return the label(s) as a comma separated list in an attribute of the element.
The problem is when multiple instances are used in a select and the user selects one or more items from different
instances I don’t see a way to iterate through all possible instances looking for the corresponding labels, create a comma
separated list and store it in the attribute. It seems like it would be easer to just look at the <xforms:select> control itself
since it contains all the values and labels.
 
Below is a fragment from my xform. It shows itemssets from two sources being used by a single select. On the
xforms-value-changed event the values are used to get the labels and store them in an attribute. But this only
works correctly if just one <xforms:itemset> is used.
 
<xforms:select ref="serverOperatingSystem">
 <xforms:label class="fieldLabel">Operating System:</xforms:label>
 <!-- This Itemset is hard coded in a instance in the form -->
 <xforms:itemset nodeset="xxforms:instance('addDatabase-serverOperatingSystem-instance')/row">
  <xforms:label class="fieldLabel" ref="label"/>
  <xforms:value ref="value"/>
 </xforms:itemset>
 
 <!-- This Itemset is returned from an XPL (data stored in db) -->
 <xforms:itemset nodeset="xxforms:instance('valueListLK-addDatabase-serverOperatingSystem-15-instance')/row" model="valueListLK-addDatabase-serverOperatingSystem-15-model">
  <xforms:label class="fieldLabel" ref="label"/>
  <xforms:value ref="value"/>
 </xforms:itemset>
 
 <!-- Always want to capture the selected label element(s) of the select -->
 <xforms:action ev:event="xforms-value-changed">
  <xxforms:variable name="theLabel" select="string-join(for $value in tokenize(xxforms:instance('addServers-instance')/addDatabase[xxforms:index('addDatabase-repeat')]/serverOperatingSystem, '\s')
  return xxforms:instance('valueListLK-addDatabase-serverOperatingSystem-15-instance')/row[value = $value]/label, ',')"/>
  xforms:setvalue ref="xxforms:instance('addServers-instance')/addDatabase[xxforms:index('addDatabase-repeat')]/serverOperatingSystem/@label" value="$theLabel"/>
 </xforms:action>
 <!-- Persist initial select values both label and value (todo: get working). -->
 <xforms:action ev:event="xforms-enabled"/>
</xforms:select>
 
 
Thanks,
Martin


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws