W3C home > Mailing lists > Public > www-forms@w3.org > August 2006

RE: Query on Xforms repeat element

From: Klotz, Leigh <Leigh.Klotz@xerox.com>
Date: Wed, 16 Aug 2006 11:09:35 -0700
Message-ID: <E254B0A7E0268949ABFE5EA97B7D0CF4021EB3C9@usa7061ms01.na.xerox.net>
To: "Vineeth Varghese" <vineeth.varghese@tavant.com>, <www-forms@w3.org>
Vineeth,
You can explicitly set the value of the node /taskview/takentransition
to a value from the repeat inside the xforms:submit.
Unfortunately, it takes a small hack, since the xforms:setvalue element
changes the context node, and there's no way to get back to the current
repeat's context.
We've discussed a way to get back at the repeat node context for XForms
1.1, but for now, you can depend on the fact that the button press will
select the repeat row, and then just use the index() XPath function to
find out what row that is, and then use that as an XPath index into the
same nodeset you gave the repeat.
 
I've separated your transition labels and the submitted data into two
instances just to make it clear for myself.  This might be what you were
doing with the bind, but I decided to do it with two instances to
separate the data more clearly.  You'd probably want to do this anyway
if your buttons have separate value and localized labels. 
 
Others may come up with better ways to do this in XForms 1,1, but here's
what I'd suggest.
 
Leigh.
 
<?xml version="1.0"?>
<html xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms">
  <head>
    <title>test</title>
    <xf:model id="model">
      <xf:instance id="main">
        <data xmlns="">
          <takentransition/>
        </data>
      </xf:instance>
 
      <xf:instance id="buttons">
        <data xmlns="">
          <taskview>
            <transition>Back</transition>
            <transition>Save</transition>
            <transition>Next</transition>
          </taskview>
        </data>
      </xf:instance>
      <xf:submission id="transition-action"
action="http://xformstest.org/cgi-bin/showinstance.sh" method="post" />
    </xf:model>
  </head>
  <body>
    <xf:repeat id="transitions"
nodeset="instance('buttons')/taskview/transition">
       <xf:submit submission="transition-action">
        <xf:label ref="."/>
        <xf:action ev:event="DOMActivate">
          <xf:setvalue ref="instance('main')/takentransition"
value="instance('buttons')/taskview/transition[index('transitions')]"/>
        </xf:action>
      </xf:submit>
    </xf:repeat>
  </body>
</html>


________________________________

From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Vineeth Varghese
Sent: Wednesday, August 16, 2006 2:45 AM
To: www-forms@w3.org
Subject: Query on Xforms repeat element



Hi All,

 

I have a query in XForms 

 

I have a model instance like:-

<taskview>

  <transition>Back</transition>

  <transition>Save</transition>

  <transition>Next</transition>

  <takentransition/>

</taskview>

 

with <xforms:bind id="takentransition"
nodeset="/taskview/takentransition"/>

 

And I want to render each <transition> element value as buttons and
figure out which button was clicked. So what I do in the view is:-

<xforms:repeat id="transitions" nodeset="/taskview/transition">

  <xforms:submit submission="transition-action">

    <xforms:label ref="."/>

  </xforms:submit>             

</xforms:repeat>

 

So basically each element of the nodeset "/taskview/transition" - Back,
Save and Next is rendered as button on the UI. Now when a user clicks on
a button I want to figure out which button was clicked and set the name
of the button to the model instance element
"/taskview/taskentransition". 

 

In my server side application once I get the model I want to be able to
get the model instance element "/taskview/taskentransition", something
like avoiding passing a request parameter but this doesn't seem to work
(I haven't figured it out).

 

I tried listening for a DomActivate event and the set the value based on
the repeat index but later figured that we can't use the repeat index.

 

How could we achieve this?. Does the XForms spec support (I am on XForms
1.0) this because this seems to be a very basic requirement. 

 

TIA,

Vineeth.
Received on Wednesday, 16 August 2006 18:10:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:06 GMT