Copying multiple elements from one model to another

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

Copying multiple elements from one model to another

Waseem Quraishi
Hello everyone,

I've been struggling with this.  I'm trying to copy a series of elements from one model to another. Here's an overview:

I have group-instance model with all the groups information as such:
group-instance:

<groups>
  <department/>
  <location/>
  <members>
      <id/>
  </members>
</groups>

On a form, the user selects a particular department and location and then  clicks next.  I can easily get the selected department and location and populate the selected-group instance but I also want to copy the members from group-instance to selected-group which looks like this:
selected-group:
<group>
  <department/>
  <location/>
  <members>
    <id/>
  </members>
</group>

Here's the code which copies the department and location:
    <!-- Set the group's department -->
    <xforms:setvalue ev:event="DOMActivate"
                     ref="instance('selected-group')/department"
                     value="instance('group-instance')/group[index('listGroups')]/department" />
   
    <!-- Set the group's location -->
    <xforms:setvalue ev:event="DOMActivate"
                     ref="instance('selected-group')/location"
                     value="instance('group-instance')/group[index('listGroups')]/location" /> 


Thanks for your help!


--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Copying multiple elements from one model to another

Alessandro Vernet
Administrator
On 6/26/07, Waseem Quraishi <[hidden email]> wrote:
> I've been struggling with this.  I'm trying to copy a series of elements
> from one model to another. Here's an overview:
> [...]

If you want to copy a number of elements from one instance to another,
you can try using <xforms:insert>. For instance something like:

<xforms:insert context="instance('selected-group')"
origin="'instance('group-instance')/group[index('listGroups')]/*"/>

This assumes that the root element of the "selected-group" instance is
empty. If it is not, you might want to run an <xforms:delete> before
that:

<xforms:delete while="instance('selected-group')/*"
nodeset="instance('selected-group')/*"/>

This will delete all the elements inside the root element. Would this
work for you?

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
http://www.orbeon.com/



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws