I have a button that allows users to Add items to a list. There is a maximum number of items that they may add, and I want to alert them when they attempt to add more than the maximum allowed. I haven't been able to work out how to do this - could someone please point me in the right direction. Here's the pseudo code of what I want to do:
<xforms:trigger> <xforms:label>Add Item</xforms:label> <xforms:action ev:event="DOMActivate"> if(count(items) = maximum) <xforms:message level="modal">Max number of items already input</xforms:message> else <xforms:insert at="last()".../> </xforms:action> </xforms:trigger> -- 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 |
Rather than wrapping the message & insert in an if..else structure, you
just need to add an 'if' attribute to each: <xforms:message if="count(items) = maximum" level="modal">Max number of items already input</xforms:message> <xforms:insert if="not(count(items) = maximum)" at="last()".../> Adrian [hidden email] wrote: > I have a button that allows users to Add items to a list. There is a maximum number of items that they may add, and I want to alert them when they attempt to add more than the maximum allowed. I haven't been able to work out how to do this - could someone please point me in the right direction. Here's the pseudo code of what I want to do: > > <xforms:trigger> > <xforms:label>Add Item</xforms:label> > > <xforms:action ev:event="DOMActivate"> > > if(count(items) = maximum) > <xforms:message level="modal">Max number of items already input</xforms:message> > > else > <xforms:insert at="last()".../> > > </xforms:action> > </xforms:trigger> > > > > ------------------------------------------------------------------------ > > > -- > 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 |
Thanks, that works nicely. It isn't particularly elegant though in
situations where I have many things to do, and have to repeat the "if" attribute for several tags. Nonetheless, I'm happy there's a solution, thanks again. Adrian Baker wrote: > Rather than wrapping the message & insert in an if..else structure, > you just need to add an 'if' attribute to each: > > <xforms:message if="count(items) = maximum" level="modal">Max number > of items already input</xforms:message> > <xforms:insert if="not(count(items) = maximum)" at="last()".../> > > Adrian > > > [hidden email] wrote: >> I have a button that allows users to Add items to a list. There is a >> maximum number of items that they may add, and I want to alert them >> when they attempt to add more than the maximum allowed. I haven't >> been able to work out how to do this - could someone please point me >> in the right direction. Here's the pseudo code of what I want to do: >> >> <xforms:trigger> >> <xforms:label>Add Item</xforms:label> >> <xforms:action ev:event="DOMActivate"> >> if(count(items) = maximum) >> <xforms:message level="modal">Max number of items already >> input</xforms:message> >> >> else >> <xforms:insert at="last()".../> >> >> </xforms:action> >> </xforms:trigger> >> >> >> >> ------------------------------------------------------------------------ >> >> >> -- >> 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 > -- 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 |
Hi,
you can also bind conditionals to your triggers - just see the "government-forms"-example! And there you use the "relevant"-attribute. When your condition is true, the trigger will be displayed, otherwise it won't. Perhaps that's a bit more the way you'll like to do that? Marcus ----- Original Message ----- From: "Edward Priwer" <[hidden email]> To: <[hidden email]> Sent: Tuesday, April 17, 2007 9:39 AM Subject: Re: [ops-users] conditional within a trigger > Thanks, that works nicely. It isn't particularly elegant though in > situations where I have many things to do, and have to repeat the "if" > attribute for several tags. Nonetheless, I'm happy there's a solution, > thanks again. > > Adrian Baker wrote: >> Rather than wrapping the message & insert in an if..else structure, >> you just need to add an 'if' attribute to each: >> >> <xforms:message if="count(items) = maximum" level="modal">Max number >> of items already input</xforms:message> >> <xforms:insert if="not(count(items) = maximum)" at="last()".../> >> >> Adrian >> >> >> [hidden email] wrote: >>> I have a button that allows users to Add items to a list. There is a >>> maximum number of items that they may add, and I want to alert them >>> when they attempt to add more than the maximum allowed. I haven't >>> been able to work out how to do this - could someone please point me >>> in the right direction. Here's the pseudo code of what I want to do: >>> >>> <xforms:trigger> >>> <xforms:label>Add Item</xforms:label> >>> <xforms:action ev:event="DOMActivate"> >>> if(count(items) = maximum) >>> <xforms:message level="modal">Max number of items already >>> input</xforms:message> >>> >>> else >>> <xforms:insert at="last()".../> >>> >>> </xforms:action> >>> </xforms:trigger> >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> >>> -- >>> 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 >> > > -------------------------------------------------------------------------------- > > -- > 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 |
In reply to this post by Edpriwer
If you've got lots of things to do
you can group them together inside <xf:action>, and put the
conditional on that.
But you're still stuck repeating the condition twice, which isn't great. Also as Marcus mentioned you can hide/disable the trigger when the maximum number is reached. Adrian Edward Priwer wrote: Thanks, that works nicely. It isn't particularly elegant though in situations where I have many things to do, and have to repeat the "if" attribute for several tags. Nonetheless, I'm happy there's a solution, thanks again. -- 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 |
Free forum by Nabble | Edit this page |