orbeon / orbeon-forms

Orbeon Forms is an open source web forms solution. It includes an XForms engine, the Form Builder web-based form editor, and the Form Runner runtime.
http://www.orbeon.com/
GNU Lesser General Public License v2.1
514 stars 221 forks source link

xforms-model-construct-done is not leaving top-level model #1502

Open hgoetzger opened 10 years ago

hgoetzger commented 10 years ago

As described in http://discuss.orbeon.com/Why-is-xforms-model-construct-done-on-load-not-working-td4657888.html:

It looks like that xforms-model-construct-done events get not dispatched to #document, whereas xforms-ready do.

This is an issue in Orbeon Forms 4.4.0.201311042001 CE. It used to work with Orbeon Forms 3.9.0.201105152046-CE .

Thanks a lot

Regards

Heinrich

Example code:

<?xml version="1.0" encoding="UTF-8"?>

<xhtml:html
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner">

<xhtml:head>

   <xf:action ev:event="HelloWorld1">
      <xf:message>Hallo xforms-ready World</xf:message>
   </xf:action>

   <xf:action ev:event="HelloWorld2">
      <xf:message>Hallo xforms-model-construct-done World</xf:message>
   </xf:action>

   <xhtml:title>My Event</xhtml:title>

   <xf:model>
      <xf:instance>
         <my-instance xmlns=""/>
      </xf:instance>

      <xf:dispatch
         ev:event="xforms-ready"
         name="HelloWorld1"
         targetid="#document">
      </xf:dispatch>

      <xf:dispatch
         ev:event="xforms-model-construct-done"
         name="HelloWorld2"
         targetid="#document">
      </xf:dispatch>

      <xf:message ev:event="xforms-model-construct-done">xforms-model-construct-done</xf:message> 

      <xf:message ev:event="xforms-ready">xforms-ready</xf:message>

   </xf:model>

</xhtml:head>

<xhtml:body/>

</xhtml:html>
ebruchez commented 10 years ago

I do reproduce this. There is an attempt at dispatching the event, but the target cannot be found:

start handler {name: "xforms-model-construct-done", phase: "target", observer: "xf-6"}
  interpreter - start executing {action name: "xf:dispatch"}
    xf:dispatch - cannot find target, ignoring action {target id: "#document"}
  interpreter - end executing {time (ms): "0", action name: "xf:dispatch"}
end handler {time (ms): "0"}

I suspect that this is because at that time, the tree of control is not yet there, and #document is considered to be at the root of that tree.

What we might want to do is to: