Login  Register

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

Posted by Alessandro Vernet on Jan 06, 2010; 2:31am
URL: https://discuss.orbeon.com/Does-anyone-know-of-a-way-to-get-at-the-labels-through-the-xforms-select-control-tp998708p999581.html

Martin,

Hard to say; we are considering implementing this extension function  
to allow us to re-implement the existing tree component in XBL. But  
without the direct sponsorship of one of our clients, I am afraid that  
it might be a while before this gets implemented.

Alex



On Jan 5, 2010, at 7:58 AM, "Schwartzman, Martin" <[hidden email]
 > wrote:

> Alex,
>
> Thanks for the reply. Any idea of when an extension XPath function  
> that would return the "itemset" for a select or select1 might be  
> implemented?
>
> Martin
>
> -----Original Message-----
> From: Alessandro Vernet [mailto:[hidden email]]
> Sent: Monday, January 04, 2010 8:27 PM
> To: [hidden email]
> Subject: [ops-users] Re: Does anyone know of a way to get at the  
> labels through the <xforms:select> control?
>
> Martin,
>
> There is nothing in XForms that allows you to get the label for a  
> selected item in a select/select1. We have been thinking about  
> adding an extension XPath function that would return the "itemset"  
> for a select or select1. The problem we were trying to solve by  
> adding that function was different, but it would be useful in your  
> case as well.
> Until then, you'll need to figure out what the label is looking back  
> into the instances pointed to by the <xforms:itemset>, which like  
> you said can sometimes be hard to do.
>
> Alex
>
> On Monday, January 4, 2010, Schwartzman, Martin <[hidden email]
> > wrote:
>>
>>
>>
>>
>>
>> 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:i
>> ndex('addDatabase-repeat')]/serverOperatingSystem,
>> '\s')
>>   return
>> xxforms:instance('valueListLK-addDatabase-serverOperatingSystem-15-
>> ins
>> tance')/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
>>
>
> --
> Orbeon Forms - Web forms, open-source, for the Enterprise Orbeon's  
> Blog: http://www.orbeon.com/blog/ My Twitter: http://twitter.com/avernet
>
> --
> 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


--
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
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet