Events fired by Powerful buttons in Orbeon 4.2

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

Events fired by Powerful buttons in Orbeon 4.2

rovsh
Hello,

It seems with Orbeon 4.2 events fired by buttons have changed and we have an issue with them.
In our applications we have been using Orbeon buttons "workflow-send" and "save" in the following way:

Example for save:
<xforms:trigger xxforms:modal="true" id="fr-save-button" model="fr-persistence-model" ref="instance('fr-triggers-instance')/save">
    <xforms:label>
        <xhtml:img width="16" height="16" src="/apps/fr/style/images/pixelmixer/right_16.png" alt=""/>
        <xhtml:span>My save title</xhtml:span>
    </xforms:label>
</xforms:trigger>

Later in the Xforms code for "save" we handled "DOMActivate" event with "fr-save-button" as observer. For example:
<xforms:action ev:event="DOMActivate" ev:observer="fr-save-button"
                                             xmlns:xforms="http://www.w3.org/2002/xforms" 
                                             xmlns:ev="http://www.w3.org/2001/xml-events">
    <xforms:action if="xxforms:instance('fr-persistence-instance')/is-error = 'true'">
         <xforms:message level="xxforms:log-debug">Got error in form</xforms:message>
    </xforms:action>
</xforms:action>

However, once we upgraded to Orbeon 4.2. This approach does not work anymore. "Custom Save" button is not shown on Form (though it exists, but disabled). We tried to handle the same events with new powerful buttons, but it seems they are no longer in "fr-triggers-instance" instance.

Can you please tell what events are fired by new powerful "save" and "save-draft" buttons? And how can we accomplish the same tasks with these new buttons?

Thanks in advance.

-rovsh
Reply | Threaded
Open this post in threaded view
|

Re: Events fired by Powerful buttons in Orbeon 4.2

Alessandro  Vernet
Administrator
Hi rovsh,

Indeed: listening on a DOMActivate on the button by id is not working anymore, in particular because there is no specific button id you can listener for a DOMActivate on. You can see in the code below how the generic fr:process-button is now produced:

https://github.com/orbeon/orbeon-forms/blob/4.2-ce/src/resources/apps/fr/components/buttons.xsl#L38

However processes do dispatch events. For instance if you want your listener to be called before the data is saved you could listen on fr-data-save-prepare, or if you want your listener to be called after the data is saved on fr-data-save-done, both dispatched to the fr-form-model. You can see what events are dispatched when by looking at the code linked below, searching for "dispatch":

https://github.com/orbeon/orbeon-forms/blob/4.2-ce/src/main/scala/org/orbeon/oxf/fr/SimpleProcess.scala

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet