xxforms:if and choose and repeat

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

xxforms:if and choose and repeat

Robert Leftwich
I'm attempting to use the xxforms:if and/or xxforms:choose extensions inside a
repeat, but I note that the doco for them says "The test attribute must contain
an XPath expression to be evaluated against the current instance. Expressions
not starting with a '/' are considered relative to the nearest xforms:group".

I've tried a number of different ways to get this to work, including defining a
group as follows:

     <xforms:group ref="/form/logs/log[index('logRepeat')]">

but in all cases I get an exception:

"Processing terminated by xsl:message at line 730" with the xsl:message saying
"Can't find control with id = 'xforms-element-35-1'"

Is it possible to use these extensions in a repeat, if not, what other
alternatives are there to defining optional triggers in a repeat, where the
optionality is determined by a member of that repeat?

Robert





--
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: xxforms:if and choose and repeat

Robert Leftwich
Is there no answer to this problem?

Robert

PS I'm using the latest from cvs

I wrote:

> I'm attempting to use the xxforms:if and/or xxforms:choose extensions
> inside a repeat, but I note that the doco for them says "The test
> attribute must contain an XPath expression to be evaluated against the
> current instance. Expressions not starting with a '/' are considered
> relative to the nearest xforms:group".
>
> I've tried a number of different ways to get this to work, including
> defining a group as follows:
>
>     <xforms:group ref="/form/logs/log[index('logRepeat')]">
>
> but in all cases I get an exception:
>
> "Processing terminated by xsl:message at line 730" with the xsl:message
> saying "Can't find control with id = 'xforms-element-35-1'"
>
> Is it possible to use these extensions in a repeat, if not, what other
> alternatives are there to defining optional triggers in a repeat, where
> the optionality is determined by a member of that repeat?
>
> Robert



--
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: xxforms:if and choose and repeat

Alexander Žaťko
Can you post a sample of the problematic piece of code? I do not think
you are providing enough info.

A.


On Sep 29, 2005, at 2:14 AM, Robert Leftwich wrote:

> Is there no answer to this problem?
>
> Robert
>
> PS I'm using the latest from cvs
>
> I wrote:
>> I'm attempting to use the xxforms:if and/or xxforms:choose extensions
>> inside a repeat, but I note that the doco for them says "The test
>> attribute must contain an XPath expression to be evaluated against
>> the current instance. Expressions not starting with a '/' are
>> considered relative to the nearest xforms:group".
>> I've tried a number of different ways to get this to work, including
>> defining a group as follows:
>>     <xforms:group ref="/form/logs/log[index('logRepeat')]">
>> but in all cases I get an exception:
>> "Processing terminated by xsl:message at line 730" with the
>> xsl:message saying "Can't find control with id =
>> 'xforms-element-35-1'"
>> Is it possible to use these extensions in a repeat, if not, what
>> other alternatives are there to defining optional triggers in a
>> repeat, where the optionality is determined by a member of that
>> repeat?
>> Robert
>
>
> --
> 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



--
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: xxforms:if and choose and repeat

Robert Leftwich
Alexander Zatko wrote:
> Can you post a sample of the problematic piece of code? I do not think
> you are providing enough info.
>

Ok, lets say I have bunch of timers that I want to turn on and off. The
(simplified) model is as follows:

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

       <xforms:instance id="timers-instance">
         <timers xmlns="">
          <timer id="1">
             <time>
               <started date="2005-09-12" time="13:30:00"/>
               <stopped date="2005-09-12" time="16:00:00"/>
             </time>
             <time>
               <started date="2005-09-24" time="11:02:00"/>
               <stopped date="2005-09-24" time="13:02:00"/>
             </time>
          </timer>

          <timer id="2">
             <time>
               <started date="2005-09-12" time="13:30:00"/>
               <stopped date="2005-09-12" time="16:00:00"/>
             </time>
             <time>
               <started date="2005-09-24" time="11:02:00"/>
               <stopped date="" time=""/>
             </time>
          </timer>

          <timer id="3">
             <time>
               <started date="2005-09-12" time="13:30:00"/>
               <stopped date="2005-09-12" time="16:00:00"/>
             </time>
             <time>
               <started date="2005-09-24" time="11:02:00"/>
               <stopped date="2005-09-24" time="13:02:00"/>
             </time>
          </timer>

        </timers>
       </xforms:instance>

       <xforms:bind nodeset="/timers">
         <xforms:bind nodeset="timer">
           <xforms:bind nodeset="time" required="true()">
             <xforms:bind nodeset="started" >
               <xforms:bind nodeset="@date" required="true()" type="xs:date"/>
               <xforms:bind nodeset="@time" required="true()" type="xs:time"/>
             </xforms:bind>
             <xforms:bind nodeset="stopped">
               <xforms:bind nodeset="@date" type="xs:date"/>
               <xforms:bind nodeset="@time" type="xs:time"/>
             </xforms:bind>
           </xforms:bind>
         </xforms:bind>
       </xforms:bind>

       <xforms:submission id="save" method="post" replace="none"
action="/timers/save"/>

  </xforms:model>

and in the html I want to have one button for each timer that either starts or
stops the timer depending on if it is still running or not (which is determined
by the existence of a valid stopped date & time element), e.g. in the above
model rows 1 and 3 should only have a start button and row 2 only a stop button.

   <body>
         <xforms:group ref="/timers">
           <table>
             <tr>
               <th width="10%">Timer ID</th>
               <th width="10%">&#160;</th>
             </tr>
             <xforms:repeat nodeset="timer" id="timerRepeat">
               <tr>
                 <td>
                   <xforms:output value="@id"/>
                 </td>
                 <td>
                   <xxforms:choose>
                     <xxforms:when test="count(time/stopped/@date[.='']) > 0">
                       <xforms:trigger>
                         <xforms:label>Stop</xforms:label>
                         <xforms:action ev:event="DOMActivate" >
                           <xforms:setvalue ref="time[last()]/stopped/@date"
value="adjust-date-to-timezone(current-date(), ())"/>
                           <xforms:setvalue ref="time[last()]/stopped/@time"
value="xs:time(concat(substring(xs:string(adjust-time-to-timezone(current-time(),
())), 1, 5), ':00'))"/>
                           <xforms:recalculate model="main-model"/>
                           <xforms:send submission="save"/>
                         </xforms:action>
                       </xforms:trigger>
                     </xxforms:when>

                     <xxforms:otherwise>

                       <xforms:trigger>
                         <xforms:label>Start</xforms:label>
                         <xforms:action ev:event="DOMActivate" >
                           <xforms:insert nodeset="time" at="last()"
position="after"/>
                           <xforms:setvalue ref="time[last()]/started/@date"
value="adjust-date-to-timezone(current-date(), ())"/>
                           <xforms:setvalue ref="time[last()]/started/@time"
value="xs:time(concat(substring(xs:string(adjust-time-to-timezone(current-time(),
())), 1, 5), ':00'))"/>
                           <xforms:setvalue ref="time[last()]/stopped/@date"
value="''"/>
                           <xforms:setvalue ref="time[last()]/stopped/@time"
value="''"/>
                           <xforms:recalculate model="main-model"/>
                           <xforms:send submission="save"/>
                         </xforms:action>
                       </xforms:trigger>

                     </xxforms:otherwise>
                   </xxforms:choose>

                 </td>
               </tr>
             </xforms:repeat>
         </table>
         </xforms:group>
   </body>

       
If I use this model then ops displays an error page with the error being
"Processing terminated by xsl:message at line 730" where line 730 is an
xsl:message saying "Can't find control with id = 'xforms-element-35-1'"

If I comment out the xxforms:choose then it works but (of course) both buttons
appear at all times.

Is it possible to use these extensions (xxforms:choose or xxforms:if) in a
repeat (I don't think so based on the admittedly old doco). If not, what other
alternatives are there to defining optional triggers in a repeat?

Robert




--
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: xxforms:if and choose and repeat

Alexander Žaťko
The "xxforms:choose" constructs look suspicious - I have never seen  
this used anywhere, but the Orbeon developers would probably be the  
authorities on the question of their usability.

Did you try to use xforms switch/case? It looks like that could work  
for you.

A.

On Sep 29, 2005, at 7:16 PM, Robert Leftwich wrote:

> Alexander Zatko wrote:
>> Can you post a sample of the problematic piece of code? I do not  
>> think you are providing enough info.
>
> Ok, lets say I have bunch of timers that I want to turn on and off.  
> The (simplified) model is as follows:
>
>  <xforms:model id="main-model">
>
>       <xforms:instance id="timers-instance">
>         <timers xmlns="">
>  <timer id="1">
>             <time>
>               <started date="2005-09-12" time="13:30:00"/>
>               <stopped date="2005-09-12" time="16:00:00"/>
>             </time>
>             <time>
>               <started date="2005-09-24" time="11:02:00"/>
>               <stopped date="2005-09-24" time="13:02:00"/>
>             </time>
>  </timer>
>
>  <timer id="2">
>             <time>
>               <started date="2005-09-12" time="13:30:00"/>
>               <stopped date="2005-09-12" time="16:00:00"/>
>             </time>
>             <time>
>               <started date="2005-09-24" time="11:02:00"/>
>               <stopped date="" time=""/>
>             </time>
>  </timer>
>
>  <timer id="3">
>             <time>
>               <started date="2005-09-12" time="13:30:00"/>
>               <stopped date="2005-09-12" time="16:00:00"/>
>             </time>
>             <time>
>               <started date="2005-09-24" time="11:02:00"/>
>               <stopped date="2005-09-24" time="13:02:00"/>
>             </time>
>  </timer>
>
> </timers>
>       </xforms:instance>
>
>       <xforms:bind nodeset="/timers">
>         <xforms:bind nodeset="timer">
>           <xforms:bind nodeset="time" required="true()">
>             <xforms:bind nodeset="started" >
>               <xforms:bind nodeset="@date" required="true()"  
> type="xs:date"/>
>               <xforms:bind nodeset="@time" required="true()"  
> type="xs:time"/>
>             </xforms:bind>
>             <xforms:bind nodeset="stopped">
>               <xforms:bind nodeset="@date" type="xs:date"/>
>               <xforms:bind nodeset="@time" type="xs:time"/>
>             </xforms:bind>
>           </xforms:bind>
>         </xforms:bind>
>       </xforms:bind>
>
>       <xforms:submission id="save" method="post" replace="none"  
> action="/timers/save"/>
>
>  </xforms:model>
>
> and in the html I want to have one button for each timer that either  
> starts or stops the timer depending on if it is still running or not  
> (which is determined by the existence of a valid stopped date & time  
> element), e.g. in the above model rows 1 and 3 should only have a  
> start button and row 2 only a stop button.
>
>   <body>
>         <xforms:group ref="/timers">
>           <table>
>             <tr>
>               <th width="10%">Timer ID</th>
>               <th width="10%">&#160;</th>
>             </tr>
>             <xforms:repeat nodeset="timer" id="timerRepeat">
>               <tr>
>                 <td>
>   <xforms:output value="@id"/>
>                 </td>
>                 <td>
>                   <xxforms:choose>
>                     <xxforms:when  
> test="count(time/stopped/@date[.='']) > 0">
>                       <xforms:trigger>
>                         <xforms:label>Stop</xforms:label>
>                         <xforms:action ev:event="DOMActivate" >
>                           <xforms:setvalue  
> ref="time[last()]/stopped/@date"  
> value="adjust-date-to-timezone(current-date(), ())"/>
>                           <xforms:setvalue  
> ref="time[last()]/stopped/@time"  
> value="xs:time(concat(substring(xs:string(adjust-time-to-
> timezone(current-time(), ())), 1, 5), ':00'))"/>
>                           <xforms:recalculate model="main-model"/>
>                           <xforms:send submission="save"/>
>                         </xforms:action>
>                       </xforms:trigger>
>                     </xxforms:when>
>
>                     <xxforms:otherwise>
>
>                       <xforms:trigger>
>                         <xforms:label>Start</xforms:label>
>                         <xforms:action ev:event="DOMActivate" >
>                           <xforms:insert nodeset="time" at="last()"  
> position="after"/>
>                           <xforms:setvalue  
> ref="time[last()]/started/@date"  
> value="adjust-date-to-timezone(current-date(), ())"/>
>                           <xforms:setvalue  
> ref="time[last()]/started/@time"  
> value="xs:time(concat(substring(xs:string(adjust-time-to-
> timezone(current-time(), ())), 1, 5), ':00'))"/>
>                           <xforms:setvalue  
> ref="time[last()]/stopped/@date" value="''"/>
>                           <xforms:setvalue  
> ref="time[last()]/stopped/@time" value="''"/>
>                           <xforms:recalculate model="main-model"/>
>                           <xforms:send submission="save"/>
>                         </xforms:action>
>                       </xforms:trigger>
>
>                     </xxforms:otherwise>
>                   </xxforms:choose>
>
>                 </td>
>               </tr>
>             </xforms:repeat>
> </table>
>         </xforms:group>
>   </body>
>
>
> If I use this model then ops displays an error page with the error  
> being "Processing terminated by xsl:message at line 730" where line  
> 730 is an xsl:message saying "Can't find control with id =  
> 'xforms-element-35-1'"
>
> If I comment out the xxforms:choose then it works but (of course) both  
> buttons appear at all times.
>
> Is it possible to use these extensions (xxforms:choose or xxforms:if)  
> in a repeat (I don't think so based on the admittedly old doco). If  
> not, what other alternatives are there to defining optional triggers  
> in a repeat?
>
> Robert
>
>
> --
> 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



--
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: xxforms:if and choose and repeat

Alessandro  Vernet
Administrator
In reply to this post by Robert Leftwich
Robert,

xxforms:if and xxforms:choose are extensions that we introduced in the
past, hence the "xxforms" instead of "xforms" prefix. As those are not
standard and that you can now in most cases get the same result using
standard XForms features, we are currently not planning to support
those in the OPS 3.0 "XForms NG". (Note that those will still be
supported when using XForms in backward-compatible, non-Ajax mode.)

In your case, when there is a <stopped date =""> you want to display
the "stop" trigger, otherwise you want to display the "start" trigger.
Since you don't have any control bound to <started> and <stopped>,
bind the start trigger to the last <started> in the current <timer>
and stop trigger to the last <stopped> (e.g.
ref="time[last()]/started"). Then add a bind that makes the <started>
relevant when the corresponding <stopped> has a date, and a bind that
makes the <stopped> relevant when that element has no date. As those
elements are relevant or non-relevant the triggers that are bound to
those elements become visible or hidden.

If you want the trigger to become disabled instead of hidden, use the
readonly model item property instead of relevant. You will find
something very similar in the "XForms repeating elements" example.
There the "remove" triggers become disabled when there are no elements
left to remove.

Alex

On 9/29/05, Robert Leftwich <[hidden email]> wrote:

> Alexander Zatko wrote:
> > Can you post a sample of the problematic piece of code? I do not think
> > you are providing enough info.
> >
>
> Ok, lets say I have bunch of timers that I want to turn on and off. The
> (simplified) model is as follows:
>
>   <xforms:model id="main-model">
>
>        <xforms:instance id="timers-instance">
>          <timers xmlns="">
>           <timer id="1">
>              <time>
>                <started date="2005-09-12" time="13:30:00"/>
>                <stopped date="2005-09-12" time="16:00:00"/>
>              </time>
>              <time>
>                <started date="2005-09-24" time="11:02:00"/>
>                <stopped date="2005-09-24" time="13:02:00"/>
>              </time>
>           </timer>
>
>           <timer id="2">
>              <time>
>                <started date="2005-09-12" time="13:30:00"/>
>                <stopped date="2005-09-12" time="16:00:00"/>
>              </time>
>              <time>
>                <started date="2005-09-24" time="11:02:00"/>
>                <stopped date="" time=""/>
>              </time>
>           </timer>
>
>           <timer id="3">
>              <time>
>                <started date="2005-09-12" time="13:30:00"/>
>                <stopped date="2005-09-12" time="16:00:00"/>
>              </time>
>              <time>
>                <started date="2005-09-24" time="11:02:00"/>
>                <stopped date="2005-09-24" time="13:02:00"/>
>              </time>
>           </timer>
>
>         </timers>
>        </xforms:instance>
>
>        <xforms:bind nodeset="/timers">
>          <xforms:bind nodeset="timer">
>            <xforms:bind nodeset="time" required="true()">
>              <xforms:bind nodeset="started" >
>                <xforms:bind nodeset="@date" required="true()" type="xs:date"/>
>                <xforms:bind nodeset="@time" required="true()" type="xs:time"/>
>              </xforms:bind>
>              <xforms:bind nodeset="stopped">
>                <xforms:bind nodeset="@date" type="xs:date"/>
>                <xforms:bind nodeset="@time" type="xs:time"/>
>              </xforms:bind>
>            </xforms:bind>
>          </xforms:bind>
>        </xforms:bind>
>
>        <xforms:submission id="save" method="post" replace="none"
> action="/timers/save"/>
>
>   </xforms:model>
>
> and in the html I want to have one button for each timer that either starts or
> stops the timer depending on if it is still running or not (which is determined
> by the existence of a valid stopped date & time element), e.g. in the above
> model rows 1 and 3 should only have a start button and row 2 only a stop button.
>
>    <body>
>          <xforms:group ref="/timers">
>            <table>
>              <tr>
>                <th width="10%">Timer ID</th>
>                <th width="10%">&#160;</th>
>              </tr>
>              <xforms:repeat nodeset="timer" id="timerRepeat">
>                <tr>
>                  <td>
>                    <xforms:output value="@id"/>
>                  </td>
>                  <td>
>                    <xxforms:choose>
>                      <xxforms:when test="count(time/stopped/@date[.='']) > 0">
>                        <xforms:trigger>
>                          <xforms:label>Stop</xforms:label>
>                          <xforms:action ev:event="DOMActivate" >
>                            <xforms:setvalue ref="time[last()]/stopped/@date"
> value="adjust-date-to-timezone(current-date(), ())"/>
>                            <xforms:setvalue ref="time[last()]/stopped/@time"
> value="xs:time(concat(substring(xs:string(adjust-time-to-timezone(current-time(),
> ())), 1, 5), ':00'))"/>
>                            <xforms:recalculate model="main-model"/>
>                            <xforms:send submission="save"/>
>                          </xforms:action>
>                        </xforms:trigger>
>                      </xxforms:when>
>
>                      <xxforms:otherwise>
>
>                        <xforms:trigger>
>                          <xforms:label>Start</xforms:label>
>                          <xforms:action ev:event="DOMActivate" >
>                            <xforms:insert nodeset="time" at="last()"
> position="after"/>
>                            <xforms:setvalue ref="time[last()]/started/@date"
> value="adjust-date-to-timezone(current-date(), ())"/>
>                            <xforms:setvalue ref="time[last()]/started/@time"
> value="xs:time(concat(substring(xs:string(adjust-time-to-timezone(current-time(),
> ())), 1, 5), ':00'))"/>
>                            <xforms:setvalue ref="time[last()]/stopped/@date"
> value="''"/>
>                            <xforms:setvalue ref="time[last()]/stopped/@time"
> value="''"/>
>                            <xforms:recalculate model="main-model"/>
>                            <xforms:send submission="save"/>
>                          </xforms:action>
>                        </xforms:trigger>
>
>                      </xxforms:otherwise>
>                    </xxforms:choose>
>
>                  </td>
>                </tr>
>              </xforms:repeat>
>          </table>
>          </xforms:group>
>    </body>
>
>
> If I use this model then ops displays an error page with the error being
> "Processing terminated by xsl:message at line 730" where line 730 is an
> xsl:message saying "Can't find control with id = 'xforms-element-35-1'"
>
> If I comment out the xxforms:choose then it works but (of course) both buttons
> appear at all times.
>
> Is it possible to use these extensions (xxforms:choose or xxforms:if) in a
> repeat (I don't think so based on the admittedly old doco). If not, what other
> alternatives are there to defining optional triggers in a repeat?
>
> Robert
>
>
>
>
>
> --
> 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
>
>
>


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