如何使用Orbeon表单按钮发送电子邮件单击?

时间:2017-11-21 07:21:10

标签: orbeon

用户在文本框中输入电子邮件(在对话框中),如图像表单预览中所示:enter image description here,用户单击SEND EMAIL按钮(id =“btnDialogBox-control”)。我想发送电子邮件给用户输入的电子邮件,其格式为“AAA”的PDF附件。

这是对话框代码(电子邮件地址)

            <xxf:dialog 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"/>
                    <xf:action event="DOMActivate">
                                    <!-- Operation to perform -->
                    </xf:action>
                </xf:trigger>
            </xxf:dialog>

以下是表单设计代码

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
     xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
     xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
     xmlns:saxon="http://saxon.sf.net/"
     xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
     xmlns:xf="http://www.w3.org/2002/xforms"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:sql="http://orbeon.org/oxf/xml/sql"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     xmlns:xi="http://www.w3.org/2001/XInclude"
     xmlns:exf="http://www.exforms.org/exf/1-0"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<xh:head>
    <xh:title>AAA</xh:title>
    <xf:model id="fr-form-model" xxf:expose-xpath-types="true">

        <!-- Main instance -->
        <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
            <form>
                <section-1>
                    <textBoxName/>
                    <docID/>
                    <btnSave/>
                    <textBoxDialog/>
                    <btnDialogBox/>
                </section-1>
            </form>
        </xf:instance>

        <!-- Bindings -->
        <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
            <xf:bind id="section-1-bind" name="section-1" ref="section-1">
                <xf:bind id="textBoxName-bind" name="textBoxName" ref="textBoxName"
                         xxf:whitespace="trim"/>
                <xf:bind id="btnSave-bind" ref="btnSave" name="btnSave"/>
                <xf:bind id="textBoxDialog-bind" name="textBoxDialog" ref="textBoxDialog"
                         type="xf:email"
                         xxf:whitespace="trim"/>
                <xf:bind id="btnDialogBox-bind" ref="btnDialogBox" name="btnDialogBox"/>
                <xf:bind id="docID-bind" ref="docID" name="docID" xxf:whitespace="trim"
                         calculate="xxf:instance('fr-parameters-instance')/document"
                         relevant="false"/>
            </xf:bind>
        </xf:bind>

        <!-- Metadata -->
        <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
            <metadata>
                <application-name>TEST</application-name>
                <form-name>TESTING</form-name>
                <title xml:lang="en">AAA</title>
                <description xml:lang="en"/>
            </metadata>
        </xf:instance>

        <!-- Attachments -->
        <xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
            <attachments>
                <css mediatype="text/css" filename="" size=""/>
                <pdf mediatype="application/pdf" filename="" size=""/>
            </attachments>
        </xf:instance>

        <!-- All form resources -->
        <xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all">
            <resources>
                <resource xml:lang="en">
                    <section-1>
                        <label>TEST</label>
                    </section-1>
                    <textBoxName>
                        <label>Name</label>
                        <hint/>
                    </textBoxName>
                    <docID>
                        <label>Doc ID</label>
                        <hint/>
                    </docID>
                    <btnSave>
                        <label>SAVE</label>
                        <hint/>
                    </btnSave>
                    <textBoxDialog>
                        <label>Recipient Email</label>
                        <hint/>
                    </textBoxDialog>
                    <btnDialogBox>
                        <label>SEND EMAIL</label>
                        <hint/>
                    </btnDialogBox>
                </resource>
            </resources>
        </xf:instance>

        <!-- Utility instances for services -->
        <xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
            <request/>
        </xf:instance>
        <xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
            <response/>
        </xf:instance>
    </xf:model>
</xh:head>
<xh:body>
    <fr:view>
        <fr:body xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xbl="http://www.w3.org/ns/xbl"
                 xmlns:oxf="http://www.orbeon.com/oxf/processors">
            <fr:section id="section-1-control" bind="section-1-bind">
                <xf:label ref="$form-resources/section-1/label"/>
                <fr:grid>
                    <xh:tr>
                        <xh:td>
                            <xf:input id="textBoxName-control" bind="textBoxName-bind">
                                <xf:label ref="$form-resources/textBoxName/label"/>
                                <xf:hint ref="$form-resources/textBoxName/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                            </xf:input>
                        </xh:td>
                        <xh:td>
                            <xf:input id="docID-control" bind="docID-bind">
                                <xf:label ref="$form-resources/docID/label"/>
                                <xf:hint ref="$form-resources/docID/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                            </xf:input>
                        </xh:td>
                    </xh:tr>
                    <xh:tr>
                        <xh:td>
                            <xf:trigger id="btnSave-control" bind="btnSave-bind">
                                <xf:label ref="$form-resources/btnSave/label"/>
                                <xf:hint ref="$form-resources/btnSave/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                                <xxf:show event="DOMActivate" dialog="my-dialog-id"/>
                            </xf:trigger>
                        </xh:td>
                        <xh:td/>
                    </xh:tr>
                </fr:grid>
            </fr:section>
            <xxf:dialog 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"/>
                    <xf:action event="DOMActivate">
                                    <!-- Operation to perform -->
                    </xf:action>
                </xf:trigger>
            </xxf:dialog>
        </fr:body>
    </fr:view>
</xh:body>

1 个答案:

答案 0 :(得分:0)

如果您只想从XForms运行email action,可以使用fr:run-process() XPath function执行此操作,如下所示:

<xf:action event="DOMActivate" type="xpath">
    fr:run-process('oxf.fr.detail.process', 'email')
</xf:action>

如果您想做更复杂的事情,可能需要在properties-local.xml中定义一个流程,并使用fr:run-process-by-name()按名称调用该流程。