Table repeat bind

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

Table repeat bind

joac
Hi again,

I don't know if it is posible to change a value of a xforms:output inside a repeat table and automatically update all other xforms:outputs of the table. Let me explain:
I am implementing a personal agenda using a table and if the user wants to add an event at a certain time all the future events must change its time automatically. I know this can be implemented with a submission, but can be implemented using a bind?

Thanks again!
Jordi



--
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: Table repeat bind

Erik Bruchez
Administrator
Jordi,

I don't see why you wouldn't be able to do this, but could you provide a
concrete example? It is hard to explain things in a complete vacuum.

-Erik

[hidden email] wrote:
> Hi again,
>
> I don't know if it is posible to change a value of a xforms:output inside a repeat table and automatically update all other xforms:outputs of the table. Let me explain:
> I am implementing a personal agenda using a table and if the user wants to add an event at a certain time all the future events must change its time automatically. I know this can be implemented with a submission, but can be implemented using a bind?
>
> Thanks again!
> Jordi

--
Orbeon - XForms Everywhere:
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
Reply | Threaded
Open this post in threaded view
|

RE: Table repeat bind

joac
Dear Erik, sorry for my explanations...

I've prepared an example xsl. Basically it shows a table with an event
scheduling, where for each row we have begin hour, duration, name of the
event and two buttons: insert and remove.
For each row (or event) we calculate the hour as previous row hour +
previous row duration.

What I need is when the user presses insert or remove button, change
automatically the scheduling of ALL the future events. Now I am able to
change only the next row.
I have put a bind using the index of the repeat, but I don't know if I can
put a loop in the bind or something similar. I hope you can test it easily.

Regards,
Jordi
THIS IS THE XSL FILE

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">

        <xhtml:head>
                <xhtml:title>Schedule</xhtml:title>

                <!--link href="styles.css" rel="stylesheet"
type="text/css"/-->

                <xforms:model id="main-model">

                        <!-- This instance contains the list of documents to
display -->
                        <xforms:instance id="schedule-data">
                                <Schedule xmlns="">
                                        <Event hour="0" duration="1"
name="meeting x"/>
                                        <Event hour="1" duration="3"
name="meeting y"/>
                                        <Event hour="4" duration="2"
name="meeting z"/>
                                        <Event hour="6" duration="1"
name="meeting z"/>
                                        <Event hour="7" duration="1"
name="meeting z"/>
                                </Schedule>
                        </xforms:instance>

                        <xforms:instance id="triggers">
                                <triggers xmlns="">
                                        <remove-child/>
                                </triggers>
                        </xforms:instance>


                        <xforms:bind
nodeset="instance('triggers')/remove-child"
relevant="count(instance('schedule-data')/Event) &gt; 1"/>


                        <xforms:bind nodeset="instance('schedule-data')">

                                <xforms:bind
nodeset="Event[index('i_event')]/@hour" readonly="false()"
                                             calculate="if (index('i_event')
&gt; 1) then (instance('schedule-data')/Event[index('i_event')-1]/@hour +
instance('schedule-data')/Event[index('i_event')-1]/@duration) else ."
                                             constraint=". castable as
xs:dateTime"/>
                        </xforms:bind>


                        <xforms:submission action="/tmg-epg/dbg"
id="dbg-submission" method="post" ref="instance('schedule-data')"/>
                </xforms:model>
        </xhtml:head>

        <xhtml:body>
                <xforms:group ref="instance('schedule-data')">

                        <br/>


                        <xhtml:table class="gridtable" width="750">
                                <xhtml:tr>
                                        <xhtml:th>Hour</xhtml:th>
                                        <xhtml:th>Duration</xhtml:th>
                                        <xhtml:th>Event</xhtml:th>
                                        <xhtml:th>Insert</xhtml:th>
                                        <xhtml:th>Remove</xhtml:th>
                                </xhtml:tr>

                                <xforms:repeat nodeset="Event" id="i_event">

                                        <xhtml:tr>
                                                <xhtml:td align="center">
                                                        <xforms:input
ref="@hour"/>
                                                </xhtml:td>
                                                <xhtml:td align="center">
                                                        <xforms:input
ref="@duration"/>
                                                </xhtml:td>
                                                <xhtml:td align="center">
                                                        <xforms:input
ref="@name"/>
                                                </xhtml:td>

                                                <xhtml:td>
                                                        <xforms:trigger>
       
<xforms:label>Insert</xforms:label>
       
<xforms:action ev:event="DOMActivate">
       
<xforms:insert nodeset="instance('schedule-data')/Event"
at="index('i_event')" position="after"/>
       
</xforms:action>
                                                        </xforms:trigger>
                                                </xhtml:td>

                                                <xhtml:td>
                                                        <xforms:trigger
ref="instance('triggers')/remove-child">
       
<xforms:label>Remove</xforms:label>
       
<xforms:delete ev:event="DOMActivate"
nodeset="instance('schedule-data')/Event" at="index('i_event')"/>
       
<xforms:recalculate/>
                                                        </xforms:trigger>
                                                </xhtml:td>
                                        </xhtml:tr>
                                </xforms:repeat>
                        </xhtml:table>
                </xforms:group>
        </xhtml:body>
</xhtml:html>





--
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: Table repeat bind

Erik Bruchez
Administrator
Jordi,

This is an easy one. Think in terms of the XML document (XForms
instance) rather than in terms of xforms:repeat:

<xforms:bind
   nodeset="Event/@hour"
   readonly="false()"
   calculate="if (count(../preceding-sibling::Event) > 0)
              then (../preceding-sibling::Event[1]/@hour
                    + ../preceding-sibling::Event[1]/@duration)
              else ."
   constraint=". castable as xs:dateTime"/>

-Erik

Jordi Amatller wrote:

> Dear Erik, sorry for my explanations...
>
> I've prepared an example xsl. Basically it shows a table with an event
> scheduling, where for each row we have begin hour, duration, name of the
> event and two buttons: insert and remove.
> For each row (or event) we calculate the hour as previous row hour +
> previous row duration.
>
> What I need is when the user presses insert or remove button, change
> automatically the scheduling of ALL the future events. Now I am able to
> change only the next row.
> I have put a bind using the index of the repeat, but I don't know if I can
> put a loop in the bind or something similar. I hope you can test it easily.
>
> Regards,
> Jordi
> THIS IS THE XSL FILE
>
> <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xforms="http://www.w3.org/2002/xforms"
> xmlns:xi="http://www.w3.org/2001/XInclude"
> xmlns:ev="http://www.w3.org/2001/xml-events"
>             xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
>
> <xhtml:head>
> <xhtml:title>Schedule</xhtml:title>
>
> <!--link href="styles.css" rel="stylesheet"
> type="text/css"/-->
>
> <xforms:model id="main-model">
>
> <!-- This instance contains the list of documents to
> display -->
> <xforms:instance id="schedule-data">
> <Schedule xmlns="">
> <Event hour="0" duration="1"
> name="meeting x"/>
> <Event hour="1" duration="3"
> name="meeting y"/>
> <Event hour="4" duration="2"
> name="meeting z"/>
> <Event hour="6" duration="1"
> name="meeting z"/>
> <Event hour="7" duration="1"
> name="meeting z"/>
> </Schedule>
> </xforms:instance>
>
> <xforms:instance id="triggers">
> <triggers xmlns="">
> <remove-child/>
> </triggers>
> </xforms:instance>
>
>
> <xforms:bind
> nodeset="instance('triggers')/remove-child"
> relevant="count(instance('schedule-data')/Event) &gt; 1"/>
>
>
> <xforms:bind nodeset="instance('schedule-data')">
>
> <xforms:bind
> nodeset="Event[index('i_event')]/@hour" readonly="false()"
>             calculate="if (index('i_event')
> &gt; 1) then (instance('schedule-data')/Event[index('i_event')-1]/@hour +
> instance('schedule-data')/Event[index('i_event')-1]/@duration) else ."
>             constraint=". castable as
> xs:dateTime"/>
> </xforms:bind>
>
>
> <xforms:submission action="/tmg-epg/dbg"
> id="dbg-submission" method="post" ref="instance('schedule-data')"/>
> </xforms:model>
> </xhtml:head>
>
> <xhtml:body>
> <xforms:group ref="instance('schedule-data')">
>
> <br/>
>
>
> <xhtml:table class="gridtable" width="750">
> <xhtml:tr>
> <xhtml:th>Hour</xhtml:th>
> <xhtml:th>Duration</xhtml:th>
> <xhtml:th>Event</xhtml:th>
> <xhtml:th>Insert</xhtml:th>
> <xhtml:th>Remove</xhtml:th>
> </xhtml:tr>
>
> <xforms:repeat nodeset="Event" id="i_event">
>
> <xhtml:tr>
> <xhtml:td align="center">
> <xforms:input
> ref="@hour"/>
> </xhtml:td>
> <xhtml:td align="center">
> <xforms:input
> ref="@duration"/>
> </xhtml:td>
> <xhtml:td align="center">
> <xforms:input
> ref="@name"/>
> </xhtml:td>
>
> <xhtml:td>
> <xforms:trigger>
>
> <xforms:label>Insert</xforms:label>
>
> <xforms:action ev:event="DOMActivate">
>
> <xforms:insert nodeset="instance('schedule-data')/Event"
> at="index('i_event')" position="after"/>
>
> </xforms:action>
> </xforms:trigger>
> </xhtml:td>
>
> <xhtml:td>
> <xforms:trigger
> ref="instance('triggers')/remove-child">
>
> <xforms:label>Remove</xforms:label>
>
> <xforms:delete ev:event="DOMActivate"
> nodeset="instance('schedule-data')/Event" at="index('i_event')"/>
>
> <xforms:recalculate/>
> </xforms:trigger>
> </xhtml:td>
> </xhtml:tr>
> </xforms:repeat>
> </xhtml:table>
> </xforms:group>
> </xhtml:body>
> </xhtml:html>
--
Orbeon - XForms Everywhere:
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
Reply | Threaded
Open this post in threaded view
|

RE: Table repeat bind

joac
Thanks! Just what I need. For you everything is easy ;)

Jordi
 

-----Mensaje original-----
De: Erik Bruchez [mailto:[hidden email]] En nombre de Erik Bruchez
Enviado el: viernes, 18 de agosto de 2006 1:05
Para: [hidden email]
Asunto: Re: [ops-users] Table repeat bind

Jordi,

This is an easy one. Think in terms of the XML document (XForms
instance) rather than in terms of xforms:repeat:

<xforms:bind
   nodeset="Event/@hour"
   readonly="false()"
   calculate="if (count(../preceding-sibling::Event) > 0)
              then (../preceding-sibling::Event[1]/@hour
                    + ../preceding-sibling::Event[1]/@duration)
              else ."
   constraint=". castable as xs:dateTime"/>

-Erik

Jordi Amatller wrote:

> Dear Erik, sorry for my explanations...
>
> I've prepared an example xsl. Basically it shows a table with an event
> scheduling, where for each row we have begin hour, duration, name of the
> event and two buttons: insert and remove.
> For each row (or event) we calculate the hour as previous row hour +
> previous row duration.
>
> What I need is when the user presses insert or remove button, change
> automatically the scheduling of ALL the future events. Now I am able to
> change only the next row.
> I have put a bind using the index of the repeat, but I don't know if I can
> put a loop in the bind or something similar. I hope you can test it
easily.

>
> Regards,
> Jordi
> THIS IS THE XSL FILE
>
> <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xforms="http://www.w3.org/2002/xforms"
> xmlns:xi="http://www.w3.org/2001/XInclude"
> xmlns:ev="http://www.w3.org/2001/xml-events"
>             xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
>
> <xhtml:head>
> <xhtml:title>Schedule</xhtml:title>
>
> <!--link href="styles.css" rel="stylesheet"
> type="text/css"/-->
>
> <xforms:model id="main-model">
>
> <!-- This instance contains the list of documents to
> display -->
> <xforms:instance id="schedule-data">
> <Schedule xmlns="">
> <Event hour="0" duration="1"
> name="meeting x"/>
> <Event hour="1" duration="3"
> name="meeting y"/>
> <Event hour="4" duration="2"
> name="meeting z"/>
> <Event hour="6" duration="1"
> name="meeting z"/>
> <Event hour="7" duration="1"
> name="meeting z"/>
> </Schedule>
> </xforms:instance>
>
> <xforms:instance id="triggers">
> <triggers xmlns="">
> <remove-child/>
> </triggers>
> </xforms:instance>
>
>
> <xforms:bind
> nodeset="instance('triggers')/remove-child"
> relevant="count(instance('schedule-data')/Event) &gt; 1"/>
>
>
> <xforms:bind nodeset="instance('schedule-data')">
>
> <xforms:bind
> nodeset="Event[index('i_event')]/@hour" readonly="false()"
>             calculate="if (index('i_event')
> &gt; 1) then (instance('schedule-data')/Event[index('i_event')-1]/@hour +
> instance('schedule-data')/Event[index('i_event')-1]/@duration) else ."
>             constraint=". castable as
> xs:dateTime"/>
> </xforms:bind>
>
>
> <xforms:submission action="/tmg-epg/dbg"
> id="dbg-submission" method="post" ref="instance('schedule-data')"/>
> </xforms:model>
> </xhtml:head>
>
> <xhtml:body>
> <xforms:group ref="instance('schedule-data')">
>
> <br/>
>
>
> <xhtml:table class="gridtable" width="750">
> <xhtml:tr>
> <xhtml:th>Hour</xhtml:th>
> <xhtml:th>Duration</xhtml:th>
> <xhtml:th>Event</xhtml:th>
> <xhtml:th>Insert</xhtml:th>
> <xhtml:th>Remove</xhtml:th>
> </xhtml:tr>
>
> <xforms:repeat nodeset="Event" id="i_event">
>
> <xhtml:tr>
> <xhtml:td align="center">
> <xforms:input
> ref="@hour"/>
> </xhtml:td>
> <xhtml:td align="center">
> <xforms:input
> ref="@duration"/>
> </xhtml:td>
> <xhtml:td align="center">
> <xforms:input
> ref="@name"/>
> </xhtml:td>
>
> <xhtml:td>
> <xforms:trigger>
>
> <xforms:label>Insert</xforms:label>
>
> <xforms:action ev:event="DOMActivate">
>
> <xforms:insert nodeset="instance('schedule-data')/Event"
> at="index('i_event')" position="after"/>
>
> </xforms:action>
> </xforms:trigger>
> </xhtml:td>
>
> <xhtml:td>
> <xforms:trigger
> ref="instance('triggers')/remove-child">
>
> <xforms:label>Remove</xforms:label>
>
> <xforms:delete ev:event="DOMActivate"
> nodeset="instance('schedule-data')/Event" at="index('i_event')"/>
>
> <xforms:recalculate/>
> </xforms:trigger>
> </xhtml:td>
> </xhtml:tr>
> </xforms:repeat>
> </xhtml:table>
> </xforms:group>
> </xhtml:body>
> </xhtml:html>
--
Orbeon - XForms Everywhere:
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