Swapping items in a repeat structure

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

Swapping items in a repeat structure

Mark Gibson-8
Hi,
I've been experimenting with the ability to swap items
in an xforms:repeat structure.

Each item has an 'Up' and 'Down' trigger next to it
which basically moves the element up or down in the instance.

I've attached a demonstration of this, it can be ran
from the OPS XForms sandbox.

There are a few problems though that I can't figure out:

1. Clicking on a button doesn't always selected the
    associated item, so instead the action occurs on
    a different item!
    Using the triggers next to each item, try:
    click 'Down' on item 'One', items 'One' and 'Two'
    should swap ok. Then click 'Down' on item 'Two',
    I find that item 'One' continues to move down.

2. Is there a way to disable 'Up' on the top item, and
    'Down' on the last item. I guess this could be done
    if there was a way of getting the index of an actual
    item, ie. like position() in XSLT, rather than just
    the selected item using index().
    The trouble is, I find that position() always returns 1.
    If this was possible it could also solve problem 1.

Now, I've also tried a toolbar approach too, (the 'Up'/'Down'
buttons below the list) but this can produce some wierd effects
too, try selecting an item and clicking 'Down' until it
reaches the bottom - it isn't deleted from it previous position!

Can anyone shed any light on any of this?

Cheers
- Mark Gibson


--
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

move-test.xhtml (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Swapping items in a repeat structure

Alessandro  Vernet
Administrator
On 5/12/06, Mark Gibson <[hidden email]> wrote:
> 2. Is there a way to disable 'Up' on the top item, and
>     'Down' on the last item. I guess this could be done
>     if there was a way of getting the index of an actual
>     item, ie. like position() in XSLT, rather than just
>     the selected item using index().
>     The trouble is, I find that position() always returns 1.
>     If this was possible it could also solve problem 1.

Hi Mark,

We still need to get back to your relative to your first point, but
let me answer first your second question. Yes, you often need to know
your current position in the repeat, and there is no function that
directly returns this information in XForms. Instead, if you are
iterating on nodes <gaga>, you can get the position with the XPath
expression (0-based): count(preceding-sibling::gaga).

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



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

Re: Swapping items in a repeat structure

Mark Gibson-8
Alessandro Vernet wrote:

> On 5/12/06, Mark Gibson <[hidden email]> wrote:
>> 2. Is there a way to disable 'Up' on the top item, and
>>     'Down' on the last item. I guess this could be done
>>     if there was a way of getting the index of an actual
>>     item, ie. like position() in XSLT, rather than just
>>     the selected item using index().
>>     The trouble is, I find that position() always returns 1.
>>     If this was possible it could also solve problem 1.
>
> Hi Mark,
>
> We still need to get back to your relative to your first point, but
> let me answer first your second question. Yes, you often need to know
> your current position in the repeat, and there is no function that
> directly returns this information in XForms. Instead, if you are
> iterating on nodes <gaga>, you can get the position with the XPath
> expression (0-based): count(preceding-sibling::gaga).
Ah, excellent, that works a treat, I've re-attached the
example with fixes applied if anyone is interested.
The top 'Up' and bottom 'Down' buttons don't do anything weird
either, so they won't need disabling anymore.

Cheers.
- Mark


--
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

move-test.xhtml (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Swapping items in a repeat structure

Alessandro  Vernet
Administrator
Hi Mark,

So are you saying that the problem 1 in your original email has been
solved as well? That is: the Up/Down button do act on the correct
line?

Alex

On 5/23/06, Mark Gibson <[hidden email]> wrote:

> Alessandro Vernet wrote:
> > On 5/12/06, Mark Gibson <[hidden email]> wrote:
> >> 2. Is there a way to disable 'Up' on the top item, and
> >>     'Down' on the last item. I guess this could be done
> >>     if there was a way of getting the index of an actual
> >>     item, ie. like position() in XSLT, rather than just
> >>     the selected item using index().
> >>     The trouble is, I find that position() always returns 1.
> >>     If this was possible it could also solve problem 1.
> >
> > Hi Mark,
> >
> > We still need to get back to your relative to your first point, but
> > let me answer first your second question. Yes, you often need to know
> > your current position in the repeat, and there is no function that
> > directly returns this information in XForms. Instead, if you are
> > iterating on nodes <gaga>, you can get the position with the XPath
> > expression (0-based): count(preceding-sibling::gaga).
>
> Ah, excellent, that works a treat, I've re-attached the
> example with fixes applied if anyone is interested.
> The top 'Up' and bottom 'Down' buttons don't do anything weird
> either, so they won't need disabling anymore.
>
> Cheers.
> - Mark
>
>
>
> --
> 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
>
>
>
>

--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



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

Re: Swapping items in a repeat structure

Mark Gibson-8
Alessandro Vernet wrote:
> Hi Mark,
>
> So are you saying that the problem 1 in your original email has been
> solved as well? That is: the Up/Down button do act on the correct
> line?

Yes, when using preceding-sibling::item.



--
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: Swapping items in a repeat structure

Alessandro  Vernet
Administrator
On 5/23/06, Mark Gibson <[hidden email]> wrote:
> Yes, when using preceding-sibling::item.

OK, good then.

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



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