sending events to repeated controls within an XBL component

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

sending events to repeated controls within an XBL component

Philip.Cantin
Hey All,

I'm a bit puzzled as to how to send events to repeated controls.

In the reproducible example attached, I have the main XHTML document which contains an 'idinfo' XBL component and a "Dispatch Event" trigger. When the "Dispatch Event" trigger is clicked, 'event1' is dispatched to the XBL component. 'Event2' is then dispatched by the <xbl:handler> element once 'event1' is observed. However, the observer for 'event2' is a trigger within a repeat, and I'd like to be able to have the event take place for ALL repeated triggers. At the moment, it seems to just take place with one of them (hence only one 'idinfo' element is being inserted within the 'test' instance).

What am I doing wrong here? I am contemplating wrapping an <xforms:dispatch> event around an <xforms:action> statement with the xxforms:iterate attribute, but I wanted to make sure this was possible, especially with nested elements.

Thanks in advance for any help or suggestions! :-)


---Philip


xforms-xbl-test2.zip
Reply | Threaded
Open this post in threaded view
|

Re: sending events to repeated controls within an XBL component

Erik Bruchez
Administrator
Philip,

The issue is that you need to dispatch an event to each repeat iteration.

One way is to setindex to all the iterations and then dispatch, like this:

<xbl:handler event="event1" phase="target">
    <xxforms:variable name="initial-index" select="index('idinfo-repeat')"/>
    <xf:action xxforms:iterate="idinfo">
        <xf:setindex repeat="idinfo-repeat" index="position()"/>
        <xf:dispatch name="event2" targetid="event-trigger"/>
    </xf:action>
    <xf:setindex repeat="idinfo-repeat" index="$initial-index"/>
</xbl:handler>

-Erik

Philip.Cantin wrote
Hey All,

I'm a bit puzzled as to how to send events to repeated controls.

In the reproducible example attached, I have the main XHTML document which contains an 'idinfo' XBL component and a "Dispatch Event" trigger. When the "Dispatch Event" trigger is clicked, 'event1' is dispatched to the XBL component. 'Event2' is then dispatched by the <xbl:handler> element once 'event1' is observed. However, the observer for 'event2' is a trigger within a repeat, and I'd like to be able to have the event take place for ALL repeated triggers. At the moment, it seems to just take place with one of them (hence only one 'idinfo' element is being inserted within the 'test' instance).

What am I doing wrong here? I am contemplating wrapping an <xforms:dispatch> event around an <xforms:action> statement with the xxforms:iterate attribute, but I wanted to make sure this was possible, especially with nested elements.

Thanks in advance for any help or suggestions! :-)


---Philip


xforms-xbl-test2.zip
Reply | Threaded
Open this post in threaded view
|

Re: sending events to repeated controls within an XBL component

Erik Bruchez
Administrator
 And here is a simple example showing this without XBL:

  http://pastie.org/597379

-Erik

Erik Bruchez wrote
Philip,

The issue is that you need to dispatch an event to each repeat iteration.

One way is to setindex to all the iterations and then dispatch, like this:

<xbl:handler event="event1" phase="target">
    <xxforms:variable name="initial-index" select="index('idinfo-repeat')"/>
    <xf:action xxforms:iterate="idinfo">
        <xf:setindex repeat="idinfo-repeat" index="position()"/>
        <xf:dispatch name="event2" targetid="event-trigger"/>
    </xf:action>
    <xf:setindex repeat="idinfo-repeat" index="$initial-index"/>
</xbl:handler>

-Erik

Philip.Cantin wrote
Hey All,

I'm a bit puzzled as to how to send events to repeated controls.

In the reproducible example attached, I have the main XHTML document which contains an 'idinfo' XBL component and a "Dispatch Event" trigger. When the "Dispatch Event" trigger is clicked, 'event1' is dispatched to the XBL component. 'Event2' is then dispatched by the <xbl:handler> element once 'event1' is observed. However, the observer for 'event2' is a trigger within a repeat, and I'd like to be able to have the event take place for ALL repeated triggers. At the moment, it seems to just take place with one of them (hence only one 'idinfo' element is being inserted within the 'test' instance).

What am I doing wrong here? I am contemplating wrapping an <xforms:dispatch> event around an <xforms:action> statement with the xxforms:iterate attribute, but I wanted to make sure this was possible, especially with nested elements.

Thanks in advance for any help or suggestions! :-)


---Philip


xforms-xbl-test2.zip
Reply | Threaded
Open this post in threaded view
|

Re: sending events to repeated controls within an XBL component

Philip.Cantin
In reply to this post by Erik Bruchez
Erik,

Thanks for the direction and the example! It works like a charm!


---Philip

Erik Bruchez wrote
Philip,

The issue is that you need to dispatch an event to each repeat iteration.

One way is to setindex to all the iterations and then dispatch, like this:

<xbl:handler event="event1" phase="target">
    <xxforms:variable name="initial-index" select="index('idinfo-repeat')"/>
    <xf:action xxforms:iterate="idinfo">
        <xf:setindex repeat="idinfo-repeat" index="position()"/>
        <xf:dispatch name="event2" targetid="event-trigger"/>
    </xf:action>
    <xf:setindex repeat="idinfo-repeat" index="$initial-index"/>
</xbl:handler>

-Erik