RE: How do I get 2 values from "xforms:select1" control

Hi Anjali,
 
I'm not completely sure I understand the question, but let's see. You have a
xf:select1 that is bound to some instance, and when you make a selection you
change the value of that instance data -- as normal. However, you also want
to pick up the label that came with that value, and copy that in? Is that
right?
 
If so, you have three choices.
 
The first is to put a xf:setvalue on the xforms-value-change event of your
xf:select1. The value to be assigned is the result of doing a look-up on the
new value. If you have more than one xf:itemset and you look up values from
different sets of data in each then you will need to use the xforms-selected
event, rather than the xforms-value-changed event, since each xf:setvalue
action will be different.
 
The second option is to use xf:copy, and copy over a full element rather
than just a text node. This will be dependent on whether the source and
destination data are the same 'shape'.
 
Finally, the third option is to place the logic in the model, and use
xf:bind with @calculate. Whenever the data changes in the xf:select1, the
'look-up' will be recalculated for you.
 
Which solution is preferable will depend on what the data in your form
'means', and in particular whether the copying of the value is a UI task or
part of the model's logic. My personal preference would be to put it in the
model, and if the data can be changed in a number of different places in the
form (i.e., you have more than one control bound to the same data), the I
would *definitely* put the logic in the model.
 
Regards,
 
Mark
 
Mark Birbeck
CEO
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
w: http://www.formsPlayer.com/
b: http://internet-apps.blogspot.com/

Download our XForms processor from
http://www.formsPlayer.com/ 
 

  _____  

From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On Behalf
Of Anjali Abraham
Sent: 19 May 2005 11:02
To: www-forms@w3.org
Cc: w3c-forms@w3.org
Subject: How do I get 2 values from "xforms:select1" control


Hi All,
            I got a bit stuck on this and I was wondering if anyone has seen
any 
examples or knows how to get around it.
 
Say I've got a form with the output XML format instance data , that I'm 
planning on submitting, and some additional data to be displayed as 
output which is effectively just lookup data.
 
In this case I have:
 
<xforms:model>
      <xforms:instance id ="123" src="abc.xml"/>
            <xforms:instance id="abc">
                  <rootElement xmlns="">
                   <Element1s>      
                        <elements attr1="" attr2="" >
                              <element1 id=""/>
                              < element2 id=""/>
                              < element3 id=""/>
                              < element4 id=""></ element4>
                        </elements> 
                   </Element1s>
                  </rootElement>    
            </xforms:instance>
</xforms:model>
 
I use the instance with id=123 as my input xml which will be used to fill
the data's of various controls of Xforms of a page. Now The instance with
id=abc is my output xml's format which I will be submitting it. 
My Problem is mentioned below:
Now for "element4" I need to have the value of attribute "id" as well as the
value of the element by name element4.
The control I use is:
<xforms:select1 ref="element4/@id" appearance="minimal">
      <xforms:label>Example:  </xforms:label>
      <xforms:item>
        <xforms:label></xforms:label>
        <xforms:value>0</xforms:value>
      </xforms:item>
      <xforms:itemset nodeset="instance('123')//ElementNames">  //input xml
is used to display this control's data
         <xforms:label ref="./name" />
         <xforms:value ref="\@id" />      //this id is stored for the
element4 - attribute id. But I need also the name 
                                          //value
      </xforms:itemset>
</xforms:select1> 
 
Now how do I take the name value of whatever I had selected and need to save
that name value as the value for my output xml's element by name element4
value??????? This issue has become a work stopper for me. So Please anyone
can suggest me "How do I set the element4 value.
 
Regards,
Anjali
 

Received on Thursday, 19 May 2005 12:29:56 UTC