Search code examples
orbeon

How to get a dialog to populate on all forms in orbeon


I've got the following dialog that I can populate and use if I put it directly into the form. However, I want to put this on all forms without having to put the code into every form. I've saved the dialog into it's own separate email-dialog.xml file and I can call it using the 2nd snippet that is set inside of the properties-local.xml. The dialog shows up as a very tiny box with nothing inside except for the label "EMAIL ADDRESS" at the top where you drag the box. I can't figure out how to get the stuff inside to populate. I've recently updated to the latest version of Orbeon 2020.1.2.2021. Any help or direction would be appreciated.

<xxf:dialog     

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

id="my-dialog-id" 
appearance="full" 
level="modal" 
close="true" 
draggable="true"
visible="false">
<xf:label>EMAIL ADDRESS</xf:label>
    <xf:input id="textBoxDialog-control" bind="textBoxDialog-bind">
    <xf:label ref="$form-resources/textBoxDialog/label"/>
    <xf:hint ref="$form-resources/textBoxDialog/hint"/>
    <xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
<xf:trigger id="btnDialogBox-control" bind="btnDialogBox-bind">
    <xf:label ref="$form-resources/btnDialogBox/label"/>
    <xf:hint ref="$form-resources/btnDialogBox/hint"/>
    <xf:alert ref="$fr-resources/detail/labels/alert"/>
    <!-- send email function-->
    <xf:action event="DOMActivate" type="xpath">
        fr:run-process('oxf.fr.detail.process', 'email')
    </xf:action>
</xf:trigger>
</xxf:dialog>
<property
   as="xs:string"  
   name="oxf.fr.detail.dialogs.custom.*.*"
   value="oxf:/forms/resources/email-dialog.xml"/>
   

<property as="xs:string"  name="oxf.fr.detail.process.send.*.*">
xf:show(dialog="my-dialog-id")
</property>

Solution

  • I assume that you have, in every form, a field named textBoxDialog, which you want to be populated with the value that users enter in the textfield shown inside the dialog you're showing when users click on the Send button. I would suggest that you make two changes to the code of your dialog:

    1. In your xf:input, remove the id, or you might get a duplicate id error since you also have a control with the id textBoxDialog-control in every form.
    2. For the button inside the dialog, don't reference the label of a control btnDialogBox inside the form, but instead puts the label in the code of the dialog.

    With those changes, the dialog looks as follows:

    And this is the modified version of your code:

    <xxf:dialog
            xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xh="http://www.w3.org/1999/xhtml"
            xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
            xmlns:xf="http://www.w3.org/2002/xforms"
            xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
    
            id="my-dialog-id"
            appearance="full"
            level="modal"
            close="true"
            draggable="true"
            visible="false">
        <xf:label>EMAIL ADDRESS</xf:label>
        <xf:input bind="textBoxDialog-bind">
            <xf:label ref="$form-resources/textBoxDialog/label"/>
            <xf:hint ref="$form-resources/textBoxDialog/hint"/>
            <xf:alert ref="$fr-resources/detail/labels/alert"/>
        </xf:input>
        <xf:trigger>
            <xf:label>Send</xf:label>
            <!-- send email function-->
            <xf:action event="DOMActivate" type="xpath">
                fr:run-process('oxf.fr.detail.process', 'email')
            </xf:action>
        </xf:trigger>
    </xxf:dialog>