1

In my form file I have a submission load-data-submission which fetches some data from database, it is called on xforms-ready :

<xf:model>
...
<xf:action ev:event="xforms-ready" ev:observer="fr-form-model" if="true()">                     
     <xf:send submission="load-data-submission"/>                
 </xf:action>
...
</xf:model>

Now, I have an XBL controll which is used in this very same form. There is another submission which also fetches data etc, let's call it rest-submission. Now, I would like the rest-submission (the one inside XBL) to be called right after my load-data-submission (the one inside form file) would fetch data.

How would I do that ? I've tried put inside XBL

<xf:action ev:observer="load-data-submission"  ev:event="xforms-submit-done">
    <xf:send submission="rest-submission"/> 
</xf:action>

with no luck.

Thanks in advance.

pzeszko
  • 1,989
  • 18
  • 29

1 Answers1

0

To avoid id clashes and enable encapsulation, XBL defines a new lexical scope for ids and a new XPath context. So if from inside the XBL you refer to id load-data-submission, this refers to a load-data-submission defined within the XBL, which is most likely non-existent in your case. To reference ids outside of the XBL, you need to change the scope with the xxbl:scope="outer" attribute. The following example illustrates how to do that:

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:xbl="http://www.w3.org/ns/xbl"
      xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
      xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
      xmlns:example="http://example.com/">
    <xh:head>
        <xf:model>
            <xf:submission
                    id="get-states"
                    method="get"
                    resource="/xforms-sandbox/service/zip-states"
                    replace="instance"
                    instance="states"/>
            <xf:instance id="states">
                <empty/>
            </xf:instance>
        </xf:model>
        <xbl:xbl>
            <xbl:binding element="example|simple">
                <xbl:implementation>
                    <xf:model id="simple-model">
                        <xf:instance>
                            <internal/>
                        </xf:instance>
                    </xf:model>
                </xbl:implementation>
                <xbl:template>
                    <xf:group>
                        <xf:message ev:observer="get-states"
                                    ev:event="xforms-submit-done"
                                    xxbl:scope="outer"
                                    value="'Got event'"/>
                    </xf:group>
                </xbl:template>
            </xbl:binding>
        </xbl:xbl>
    </xh:head>
    <xh:body>
        <example:simple/>
        <xf:trigger>
            <xf:label>Get states</xf:label>
            <xf:send submission="get-states" ev:event="DOMActivate"/>
        </xf:trigger>
    </xh:body>
</xh:html>
avernet
  • 30,895
  • 44
  • 126
  • 163
  • Thanks for answer. Surprisingly, it works with but doesn't work with anything else apparently ! I mean, when I put xxble:scope="outer" to my or it doesn't work anymore, so I am able to print a message about submission but not able to send another one afterwards. Any thoughts why does it happen ? – pzeszko Jan 12 '15 at 08:55
  • Moreover, another suprising issue. In my XBL control I got some parameters which I can pass by clicking on Control's settings and inserting some values to the fields. Then, iny my XBL I check f.e. if the field contains a word 'load' and if so send appropriate submission like that : . It works everytime, BUT, when I put between xf:group the message is shown everytime, no matter if $subOn contains the word 'load' . – pzeszko Jan 12 '15 at 09:03
  • If the `` runs, at least your event handler is being called. That is already something! Now, what are trying to do in that even handler? Keep in mind that if you have `xxbl:scope="outer"`, anything nested will still in the outer scope, and those won't have access anything "inside" the XBL component. – avernet Jan 14 '15 at 07:24
  • Would you be able update the super-simple XBL component/example above to include code that reproduces the issue you're seeing? If you do, feel free to put the code in a new Gist (https://gist.github.com/), and link to it from here. – avernet Jan 14 '15 at 07:26