我使用Form Builder(版本4.9)創建包含重複網格的表單。 我還定義了一個Process按鈕,以便將表單的數據發送到Servlet(使用send()方法)。 我的目標是將表格數據保存在數據庫表中。重複網格Orbeon形式:確定相同迭代的字段值
我能夠在servlet中接收表單的數據作爲XML,但我注意到在不同的迭代中具有相同值的字段 在XML中每個值只出現一次,'for'屬性具有多個值(表示值重複的次數)。 但是,我一直無法找到匹配同一迭代的所有字段(表示一個錶行)的方法,所以我無法正確地將數據存儲在數據庫中。
例如,當我下表
HEADERS : FIELD_B - FIELD_C -
ITER_1 : FIELD_B_1 - FIELD_C_1 -
ITER_2 : FIELD_B_2 - FIELD_C_2 -
ITER_2 : FIELD_B_3 - FIELD_C_1 -
後,我得到以下XML
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<control for="e7d2bb4ac261e77159fc236e7fd922c3540756f8" name="section-1"
type="section">
<resources lang="en">
<label>Untitled Section</label>
</resources>
</control>
<control for="69ec5abdeb2df55c97bf5b1db46cce6bc841aed8" name="FIELD_A"
type="input">
<resources lang="en">
<label>FIELD_A</label>
<hint />
</resources>
<value>FIELD_A_V</value>
</control>
<control for="9749b7620379db1e8f86eeceaf52c60fa19484d2" name="FIELD_B"
type="input">
<resources lang="en">
<label>FIELD_B</label>
<hint />
</resources>
<value>FIELD_B_1</value>
</control>
<control
for="89761405fd9de1a147bdda4d2c9279062b806016 9fa491ba6b72e86919e8a02226e28572c7309311"
name="FIELD_C" type="input">
<resources lang="en">
<label>FIELD_C</label>
<hint />
</resources>
<value>FIELD_C_1</value>
</control>
<control for="9cf502968950de2af58236fe0aaaab2a4fa5ac6d" name="FIELD_B"
type="input">
<resources lang="en">
<label>FIELD_B</label>
<hint />
</resources>
<value>FIELD_B_2</value>
</control>
<control for="46337304c26fca5cf9d5e91cdf393e3d39c0fbde" name="FIELD_C"
type="input">
<resources lang="en">
<label>FIELD_C</label>
<hint />
</resources>
<value>FIELD_C_2</value>
</control>
<control for="1155463007588b06b3842c534ca678aa6f5cf665" name="FIELD_B"
type="input">
<resources lang="en">
<label>FIELD_B</label>
<hint />
</resources>
<value>FIELD_B_3</value>
</control>
</metadata>
正如你所看到的,迭代1和3,FIELD_C包含值FIELD_C_1。 解析XML時,我無法找到該字段的值的順序。我結束了不正確的表格:
HEADERS : FIELD_B - FIELD_C -
ITER_1 : FIELD_B_1 - FIELD_C_1 -
ITER_2 : FIELD_B_2 - FIELD_C_1 -
ITER_2 : FIELD_B_3 - FIELD_C_2 -
迭代2和3在FIELD_C中有錯誤的值。
如何找到重複字段值的正確順序?
我正在尋找一種解決方案,不需要在表單構建器之外操作表單定義,因爲表單將由最終用戶在不知曉XForms的情況下創建。
中屬性-那個local.xml提交按鈕是:
<property
as="xs:string"
name="oxf.fr.detail.process.OrbeonFormsPortlet.*.*">
validate-all
then send(
property = "oxf.fr.detail.send.success",
uri = "http://localhost:8080/web/guest/testlang/-/oaed-form-requests/pop_up/{xxf:get-request-header('Orbeon-Liferay-User-Id')}",
content = "metadata",
prune = "false"
)
</property>
完整形式定義是(形式包含一個字段 - FIELD_A - 外重複網格,其是不相關的問題):
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:exf="http://www.exforms.org/exf/1-0">
<xh:head>
<xh:title>TestRepeat</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>
<FIELD_A/>
<grid-3>
<grid-3-iteration>
<FIELD_B/>
<FIELD_C/>
</grid-3-iteration>
</grid-3>
</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="FIELD_A-bind" name="FIELD_A" ref="FIELD_A"/>
<xf:bind id="grid-3-bind" ref="grid-3" name="grid-3">
<xf:bind id="grid-3-iteration-bind" ref="grid-3-iteration" name="grid-3-iteration">
<xf:bind id="FIELD_B-bind" ref="FIELD_B" name="FIELD_B"/>
<xf:bind id="FIELD_C-bind" ref="FIELD_C" name="FIELD_C"/>
</xf:bind>
</xf:bind>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>OAED</application-name>
<form-name>TestRepeat</form-name>
<title xml:lang="en">TestRepeat</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">
<FIELD_B>
<label>FIELD_B</label>
<hint/>
</FIELD_B>
<FIELD_C>
<label>FIELD_C</label>
<hint/>
</FIELD_C>
<section-1>
<label>Untitled Section</label>
</section-1>
<FIELD_A>
<label>FIELD_A</label>
<hint/>
</FIELD_A>
</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:instance xxf:readonly="true" id="grid-3-template">
<grid-3-iteration>
<FIELD_B/>
<FIELD_C/>
</grid-3-iteration>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xbl="http://www.w3.org/ns/xbl">
<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="FIELD_A-control" bind="FIELD_A-bind">
<xf:label ref="$form-resources/FIELD_A/label"/>
<xf:hint ref="$form-resources/FIELD_A/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td/>
</xh:tr>
</fr:grid>
<fr:grid id="grid-3-grid" bind="grid-3-bind" repeat="content" min="1"
template="instance('grid-3-template')">
<xh:tr>
<xh:td>
<xf:input id="FIELD_B-control" bind="FIELD_B-bind">
<xf:label ref="$form-resources/FIELD_B/label"/>
<xf:hint ref="$form-resources/FIELD_B/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:input id="FIELD_C-control" bind="FIELD_C-bind">
<xf:label ref="$form-resources/FIELD_C/label"/>
<xf:hint ref="$form-resources/FIELD_C/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>