- From: Aaron Reed <aaronr@us.ibm.com>
- Date: Fri, 06 Apr 2007 17:52:09 -0500
- To: www-forms@w3.org
Hi John, Using ev:listener is how I would reuse handlers. No reason that an ev:listener can't work in XForms. To clarify actions if you had: <xf:trigger> <xf:label>handle some-other-event</xf:label> <xf:action id="handler2" ev:event="DOMActivate" ev:observer="observer2" ev:handler="#handler"> <xf:message level="modal">DOMActivate happened</xf:message> </xf:action> </xf:trigger> and you have another action with id="handler", then when the trigger is clicked, the above action would not process its contents (and thus the above message would not be shown) since it is actually only specifying what the actual handler would be, not acting as a handler itself. But whatever actions appear in xf:action with @id="handler" would be processed. I hope that this helps, --Aaron Clark, John wrote: > I am interested in reusing event handlers, and I was wondering if the combination of Xforms (1.1) and XML Events allows this. For example, say I have an event handler (an `xf:action` element) that looks like this: > > <xf:action ev:event="some-event" ev:observer="observer1" > id="handler"> > <!-- Potentially complex handler logic here --> > </xf:action> > > If I want the same handler logic to also respond to a second event (and potentially at a different observer location), I would like to not have to take the naïve approach and duplicate the entire action. The XML Events specification gives us one tool, the `ev:listener` element. "Reregistering" the above handler might look like: > > <ev:listener event="some-other-event" observer="observer2" > handler="#handler"/> > > Is the `ev:listener` element allowed in XForms, however? Also, how would the use of the relative reference in `handler="#handler"` interact with IDREF resolution in XForms[0]? If the `ev:listener` element is not allowed in XForms, then another possibility is to use the `ev:handler` attribute, which might look like this: > > <xf:action ev:event="some-other-event" ev:observer="observer2" > ev:handler="#handler"/> > > The same question about IDREF resolution applies here, though. Also, the spec says that the `action` element "causes its child actions to be invoked in the order that they are specified in the document"[1]; does that allow for pointing at a different handler? > > [0] http://www.w3.org/TR/2007/WD-xforms11-20070222/#idref-resolve > > [1] http://www.w3.org/TR/2007/WD-xforms11-20070222/#action-action > > Thanks, and take care, > > John L. Clark | Systems Analyst > | Cardio-Thoracic Surgery Research > Cleveland Clinic | 9500 Euclid Ave. | Cleveland, OH 44195 > | (216) 445-6011 > > > > > > Cleveland Clinic is ranked one of the top 3 hospitals in > America by U.S.News & World Report. Visit us online at > http://www.clevelandclinic.org for a complete listing of > our services, staff and locations. > > > Confidentiality Note: This message is intended for use > only by the individual or entity to which it is addressed > and may contain information that is privileged, > confidential, and exempt from disclosure under applicable > law. If the reader of this message is not the intended > recipient or the employee or agent responsible for > delivering the message to the intended recipient, you are > hereby notified that any dissemination, distribution or > copying of this communication is strictly prohibited. If > you have received this communication in error, please > contact the sender immediately and destroy the material in > its entirety, whether electronic or hard copy. Thank you. > > > =================================== > >
Received on Friday, 6 April 2007 22:59:43 UTC