Orbeon 获取 documentId

Orbeon get documentId

我有兴趣在提交表单时获取 documentId 并将其 link 发送给用户(即通过表单必填字段中的电子邮件)。这个想法也是调用一个网络服务并发送两个字段来建立这种关系。现在,我想在字段中查看此值。

首先,我发现我可以使用 xxforms:instance('fr-parameters-instance')/document 实现这一点,但我没有成功。

在此之后,我看到 here 现在(我正在使用 Orbeon 4.9)更改为 fr:document-id() 但似乎我仍然无法在简单的字段中看到文档 ID表格。基本上,类似于:

<xf:action ev:event="xforms-submit">
   <xf:setvalue ref="instance('fr-form-instance')/somefield" value="fr:document-id()"/>
</xf:action> 

使用 Form Builder 创建的简单示例:

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     xmlns:xi="http://www.w3.org/2001/XInclude"
     xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
     xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
     xmlns:exf="http://www.exforms.org/exf/1-0"
     xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
     xmlns:saxon="http://saxon.sf.net/"
     xmlns:sql="http://orbeon.org/oxf/xml/sql"
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
     xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<xh:head>
    <xh:title>Send OrbeonID</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">
            <form>
                <section-1>
                    <control-1/>
                </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="control-1-bind" name="control-1" ref="control-1"/>
            </xf:bind>
        </xf:bind>

        <!-- Metadata -->
        <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
            <metadata>
                <application-name>Biit</application-name>
                <form-name>SendOrbeonID</form-name>
                <title xml:lang="en">Send OrbeonID</title>
                <description xml:lang="en"/>
                <singleton>false</singleton>
            </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 -->
        <!-- Don't make readonly by default in case a service modifies the resources -->
        <xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
            <resources>
                <resource xml:lang="en">
                    <section-1>
                        <label>Untitled Section</label>
                    </section-1>
                    <control-1>
                        <label>Write something:</label>
                        <hint/>
                        <alert/>
                    </control-1>
                </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>

        <!-- Form is sent -->          
        <xf:action ev:event="xforms-submit">
            <xf:setvalue ref="instance('fr-form-instance')/section-1/control-1" value="fr:document-id()"/>
        </xf:action>                

    </xf:model>
</xh:head>
<xh:body>
    <fr:view>
        <fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
                 xmlns:oxf="http://www.orbeon.com/oxf/processors"
                 xmlns:p="http://www.orbeon.com/oxf/pipeline">
            <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="control-1-control" bind="control-1-bind">
                                <xf:label ref="$form-resources/control-1/label"/>
                                <xf:hint ref="$form-resources/control-1/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                            </xf:input>
                        </xh:td>
                        <xh:td/>
                    </xh:tr>
                </fr:grid>
            </fr:section>
        </fr:body>
    </fr:view>
</xh:body>
</xh:html>

理论上,如果我 fill up 输入字段并按下提交或保存按钮,该字段必须更新为文档 ID。但我看不到任何价值。

好消息是文档 ID 已默认作为 URL 参数发送。 URL 参数名称是 document。另见相关 documentation.

最后,我发现发送文档 ID 的方式改变了 Orbeon 中按钮的行为。

在另存为草稿按钮中:

<property as="xs:string" name="oxf.fr.detail.process.save-draft.*.*">
   save
   then send("oxf.fr.detail.save-draft.success")
   then success-message("save-draft-success")
   recover error-message("database-error")
</property>

并在 Orbeon 之外的某处定义 send 操作:

<property as="xs:boolean" name="oxf.fr.detail.new.accept-post.*.*" value="true" />
<property as="xs:string" name="oxf.fr.detail.save-draft.success.uri.*.*" value="http://localhost:8080/get-id.jsp?document={xxf:instance('fr-parameters-instance')/document}"/>
<property as="xs:string" name="oxf.fr.detail.save-draft.success.method.*.*" value="post"/>

JSP 页面 get-id.jsp 现在每次用户保存表单草稿时都会执行,但浏览器不会重定向到 JSP 页面。

更改为使用网络服务或其他操作一定很容易。

当您将表单生成器控件的计算值设置为

xxf:instance('fr-parameters-instance')/document 

您可以获得文档ID。