Can an Orbeon event in an XBL be dispatched from Javascript?

400 views Asked by At

Orbeon version: Orbeon Forms 3.8.0.201005270113

I have the following code in a Javascript file. This code is executed, but it seems like the model in the XBL is not found.

ORBEON.xforms.Document.dispatchEvent("model-name", "event-name");

Here is the model in the XBL. There are several models in the XBL. I don't see any message, so it seems as though the model isn't found. I don't see any errors in the logs.

<xforms:model id="model-name" xxforms:external-events="event-name">
  <xforms:action ev:event="event-name">
    <xforms:message>Test</xforms:message>
  </xforms:action>
</xforms:model>

Does anyone know if there is some trick to getting a dispatch to work from Javascript to XBL?

Thanks very much!

UPDATED:

Another thing that could be the problem (maybe?) is that calling the javascript from the XBL using instance(this) isn't working. I wonder if the instance of the class isn't tied to a component instance, therefore it can't find the model?

Here's the call to the javascript from the xbl that doesn't invoke the init method:

<xxforms:script>YAHOO.xbl.fr.myTest.instance(this).init();</xxforms:script>

Here's the call that does invoke the init() method:

<xxforms:script>YAHOO.xbl.fr.myTest.prototype.init();</xxforms:script>

Here's the javascript:

YAHOO.namespace("xbl.fr");
YAHOO.xbl.fr.myTest = function() {};
ORBEON.xforms.XBL.declareClass(YAHOO.xbl.fr.myTest, "xbl-fr-myTest");

YAHOO.xbl.fr.myTest.prototype = {
},

init: function() {
    alert('test');
},

valueChanged: function() {
},

};
1

There are 1 answers

2
tohuwawohu On

AFAIK you can't address the XBL-internal model directly from outside, because of its strong encapsulation.

Instead, you'll have to dispatch the event to the xbl component node. For example, if you want an instance of the fr:currency XBL to handle a certain event, you'll have to dispatch the event to that fr:currency element that's part of your XForm.

Inside the XBL, you can define xbl:handlers to act upon that event, triggering some JavaScript action or something else.