我有兴趣在提交表单时将documentId链接到用户(即通过表单的必填字段中的电子邮件)。我们的想法是调用Web服务并发送两个字段以建立这种关系。现在,我想在一个字段中看到这个值。
首先,我发现我可以使用xxforms:instance('fr-parameters-instance')/document
实现此目的,但我没有成功。
在此之后,我看到here现在(我正在使用Orbeon 4.9)更改为fr:document-id()
但似乎我仍然无法在表单的简单字段中看到文档ID 。 Bassically,如:
<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更新该字段。但我无法看到任何价值。
答案 0 :(得分:0)
好消息是文档ID默认已作为URL参数发送。 URL参数名称为document
。另请参阅相关的documentation。
答案 1 :(得分:0)
最后,我发现发送文档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页面。
更改为使用Web服务或其他操作必须简单。
答案 2 :(得分:0)
将表单构建器控件计算值设置为
时xxf:instance('fr-parameters-instance')/document
您可以获取文档ID。