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

classic Classic list List threaded Threaded
6 messages Options
mar
Reply | Threaded
Open this post in threaded view
|

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

mar
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
Reply | Threaded
Open this post in threaded view
|

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

Alessandro  Vernet
Administrator
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: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
>
--
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
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
mar
Reply | Threaded
Open this post in threaded view
|

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

mar
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
Reply | Threaded
Open this post in threaded view
|

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

Alessandro  Vernet
Administrator
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
Reply | Threaded
Open this post in threaded view
|

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

Steven Kerr
In reply to this post by Alessandro Vernet
People

My question is along the same lines as this.  When I user changes the value of a select1 list, I need the selected 'label' to be displayed in other part of the form.  I can't make the labels & values the same as the labels have spaces etc.  Is searching through the corresponding itemset for the value matching the selected value the only way to do this?  And if so does anyone have a simple example?

I am also after a way to do this with the smallest amount of code as possible as I will need to do it for 8 select1 lists on the same form.

Cheers

Steven

-----Original Message-----
From: Alessandro Vernet [mailto:[hidden email]]
Sent: Tuesday, 5 January 2010 13:27
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
Reply | Threaded
Open this post in threaded view
|

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

Steven Kerr
Okay, I have it working now :) Please ignore my question.  Doing a lookup was fine.  Sorry for the spam :(

Model extract (far too big to insluce the full tree)
---------------------------------------------------

<tests>
<test>

<results>
<testResult_1 isNumeric="false">
   <displayResult>True</displayResult>
   <numericResult></numericResult>
   <specialResult>1</specialResult>
   <tesResultStatus>Passed all specifications</tesResultStatus>
   <result_is_required>true</result_is_required>
</testResult_1>
</results>

<UDC_Pair>
   <name>true</name>
   <value>1</value>
</UDC_Pair>
<UDC_Pair>
   <name>false</name>
   <value>0</value>
</UDC_Pair>

</test>
</tests>

Select1 example:
----------------

<xforms:select1 id="specialResult_1-control" ref="ns1:results/ns1:testResult_1/ns1:specialResult" appearance="minimal" class="xforms-control xforms-select1">
   <xforms:itemset ref="xxforms:repeat-current('test-group-repeat')/ns1:UDC_List/ns1:UDC_Pair">
      <xforms:label id='testResult_1_name' ref="ns1:name"/>
      <xforms:value ref="ns1:value"/>
   </xforms:itemset>
   <xforms:setvalue ref="xxforms:repeat-current('test-group-repeat')/ns1:results/ns1:testResult_1/ns1:displayResult" ev:event="xforms-value-changed"
      value="xxforms:repeat-current('test-group-repeat')/ns1:UDC_List/ns1:UDC_Pair[ns1:value = xxforms:repeat-current('test-group-repeat')/ns1:results/ns1:testResult_1/ns1:specialResult]/ns1:name"/>
</xforms:select1>



-----Original Message-----
From: Steven Kerr
Sent: Monday, 1 February 2010 11:16
To: [hidden email]
Subject: [ops-users] RE: Re: Does anyone know of a way to get at the labels through the <xforms:select> control?

People

My question is along the same lines as this.  When I user changes the value of a select1 list, I need the selected 'label' to be displayed in other part of the form.  I can't make the labels & values the same as the labels have spaces etc.  Is searching through the corresponding itemset for the value matching the selected value the only way to do this?  And if so does anyone have a simple example?

I am also after a way to do this with the smallest amount of code as possible as I will need to do it for 8 select1 lists on the same form.

Cheers

Steven

-----Original Message-----
From: Alessandro Vernet [mailto:[hidden email]]
Sent: Tuesday, 5 January 2010 13:27
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