【问题标题】:Orbeon get documentIdOrbeon 获取 documentId
【发布时间】:2015-08-13 14:49:42
【问题描述】:

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

首先,我发现我可以使用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> 

使用表单生成器创建的简单示例:

<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 进行更新。但我看不到任何价值。

【问题讨论】:

    标签: orbeon xforms


    【解决方案1】:

    好消息是默认情况下,文档 ID 已作为 URL 参数发送。 URL 参数名称为document。另请参阅相关的documentation

    【讨论】:

    • 好的,谢谢您的回答。它接近我需要的东西。我将对其进行测试,看看我是否可以通过这种方式检索文档 ID 并继续我的过程。
    • 似乎几乎是一个解决方案。我可以更改发送操作并将 document_id 和电子邮件发送到 URL。但是我的其余服务受到保护,这就是我尝试使用 Orbeon 的标准 Web 服务功能的原因。目前,我可以将此信息发送到处理授权和重新发送数据的 JSP 页面,但可能存在更好的方法来执行此操作而无需中间 jsp 页面。
    • 不,使用 JSP 页面只是“发送”按钮的解决方案,但如果我使用“保存”按钮,您将无法继续处理表单。我不确定你写的关于“更强大的按钮”的文档是否允许我这样做或继续最初的启动网络服务的想法。
    • 我知道这已经有一段时间了,但您找到解决方案了吗?
    • 仅在我之前提出的其他解决方案中进行了解释。
    【解决方案2】:

    最后,我发现发送文档 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>
    

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

    <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 页面。

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

    【讨论】:

    • 是的,确认使用网络服务也可以。
    【解决方案3】:

    当您将表单构建器控件的计算值设置为

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

    您可以获得文档ID。

    【讨论】:

    • 是的,这正是我在接受的答案中所描述的。
    猜你喜欢
    • 1970-01-01
    • 2021-01-08
    • 2019-11-20
    • 1970-01-01
    • 1970-01-01
    • 2020-11-08
    • 2021-06-06
    • 2021-06-23
    • 1970-01-01
    相关资源
    最近更新 更多