Limiting repeats

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

Limiting repeats

Ethan Gruber
I checked the archives and came across a thread from a few months ago that touches on what I want to do.  I have an optional element, but I want to limit how many times it can repeat.  Let's say, for example, no more than two times.  Here is the thread: http://www.nabble.com/control-the-numbers-of-a-repeated-component-in-a-node-td23313475.html#a23494458 .  Here is another good source on binding/relevant: http://en.wikibooks.org/wiki/XForms/Relevant

I'm having problems putting it into practice.  I have it almost working, but I must be missing something.  Here is a bit of code:

<xforms:bind nodeset="editionstmt" relevant="count(//editionstmt) &lt; 3"/>

<xforms:trigger appearance="minimal" ref="editionstmt">
  <xforms:label>
    <img src="../apps/editor/images/add.gif"/>Add Edition Statement</xforms:label>
    <xforms:insert ev:event="DOMActivate" context="." origin="instance('editionstmt-template')" nodeset="."/>
</xforms:trigger>

<xforms:repeat nodeset="editionstmt">
   <div>
    <xforms:input ref="edition">
      <xforms:label>Edition</xforms:label>
    </xforms:input>
  </div>
</xforms:repeat>

This example disables the trigger only after it has been clicked to add a third item.  Not only does the trigger disappear, but the two existing inputs also disappear.  My guess is that I have constructed the relevant attribute incorrectly.  Does anyone know a better way of doing this?

Thanks,
Ethan Gruber


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

Re: Limiting repeats

Philip.Cantin
Ethan,

Try wrapping an xforms:group statement around your xforms:trigger element, like so:

<xforms:group ref=".[count(//editionstmt) &lt; 3]">
<xforms:trigger appearance="minimal">
  <xforms:label>
    Add Edition
Statement</xforms:label>
    <xforms:insert ev:event="DOMActivate" context="."
origin="instance('editionstmt-template')" nodeset="."/>
</xforms:trigger>
</xforms:group>

This will cause the trigger to disappear when the count of editionstmt hits 3, but it shouldn't affect anything within your xforms:repeat.

In addition, if you provide a reproducible sandbox example I could try and give you more insight as to why your previous code wasn't working as you expected it to.


---Philip


Ethan Gruber wrote
I checked the archives and came across a thread from a few months ago that
touches on what I want to do.  I have an optional element, but I want to
limit how many times it can repeat.  Let's say, for example, no more than
two times.  Here is the thread:
http://www.nabble.com/control-the-numbers-of-a-repeated-component-in-a-node-td23313475.html#a23494458.
 Here is another good source on binding/relevant:
http://en.wikibooks.org/wiki/XForms/Relevant

I'm having problems putting it into practice.  I have it almost working, but
I must be missing something.  Here is a bit of code:

<xforms:bind nodeset="editionstmt" relevant="count(//editionstmt) &lt; 3"/>

<xforms:trigger appearance="minimal" ref="editionstmt">
  <xforms:label>
    Add Edition
Statement</xforms:label>
    <xforms:insert ev:event="DOMActivate" context="."
origin="instance('editionstmt-template')" nodeset="."/>
</xforms:trigger>

<xforms:repeat nodeset="editionstmt">
   <div>
    <xforms:input ref="edition">
      <xforms:label>Edition</xforms:label>
    </xforms:input>
  </div>
</xforms:repeat>

This example disables the trigger only after it has been clicked to add a
third item.  Not only does the trigger disappear, but the two existing
inputs also disappear.  My guess is that I have constructed the relevant
attribute incorrectly.  Does anyone know a better way of doing this?

Thanks,
Ethan Gruber


--
You receive this message as a subscriber of the ops-users@ow2.org mailing list.
To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
For general help: mailto:sympa@ow2.org?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Limiting repeats

Ethan Gruber
Hi Philip,

Thanks for the help!  I got it working exactly the way I want it to.

Ethan

On Thu, Aug 20, 2009 at 11:28 AM, Philip.Cantin <[hidden email]> wrote:

Ethan,

Try wrapping an xforms:group statement around your xforms:trigger element,
like so:

<xforms:group ref=".[count(//editionstmt) &lt; 3]">
<xforms:trigger appearance="minimal">
 <xforms:label>
    ../apps/editor/images/add.gif Add Edition
Statement</xforms:label>
   <xforms:insert ev:event="DOMActivate" context="."
origin="instance('editionstmt-template')" nodeset="."/>
</xforms:trigger>
</xforms:group>

This will cause the trigger to disappear when the count of editionstmt hits
3, but it shouldn't affect anything within your xforms:repeat.

In addition, if you provide a reproducible sandbox example I could try and
give you more insight as to why your previous code wasn't working as you
expected it to.


---Philip



Ethan Gruber wrote:
>
> I checked the archives and came across a thread from a few months ago that
> touches on what I want to do.  I have an optional element, but I want to
> limit how many times it can repeat.  Let's say, for example, no more than
> two times.  Here is the thread:
> http://www.nabble.com/control-the-numbers-of-a-repeated-component-in-a-node-td23313475.html#a23494458.
>  Here is another good source on binding/relevant:
> http://en.wikibooks.org/wiki/XForms/Relevant
>
> I'm having problems putting it into practice.  I have it almost working,
> but
> I must be missing something.  Here is a bit of code:
>
> <xforms:bind nodeset="editionstmt" relevant="count(//editionstmt) &lt;
> 3"/>
>
> <xforms:trigger appearance="minimal" ref="editionstmt">
>   <xforms:label>
>      ../apps/editor/images/add.gif Add Edition
> Statement</xforms:label>
>     <xforms:insert ev:event="DOMActivate" context="."
> origin="instance('editionstmt-template')" nodeset="."/>
> </xforms:trigger>
>
> <xforms:repeat nodeset="editionstmt">
>    <div>
>     <xforms:input ref="edition">
>       <xforms:label>Edition</xforms:label>
>     </xforms:input>
>   </div>
> </xforms:repeat>
>
> This example disables the trigger only after it has been clicked to add a
> third item.  Not only does the trigger disappear, but the two existing
> inputs also disappear.  My guess is that I have constructed the relevant
> attribute incorrectly.  Does anyone know a better way of doing this?
>
> Thanks,
> Ethan Gruber
>
>
> --
> 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
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>

--
View this message in context: http://www.nabble.com/Limiting-repeats-tp25053345p25064176.html
Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.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
OW2 mailing lists service home page: http://www.ow2.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
OW2 mailing lists service home page: http://www.ow2.org/wws