我正在使用表单生成器(版本4.9)来创建包含重复网格的表单。 我还定义了一个Process按钮,以便将表单的数据发送到Servlet(使用send()方法)。 我的目标是将表单数据保存在数据库表中。
我能够在servlet中以XML的形式接收Form的数据,但我注意到在不同的迭代中具有相同值的字段, 在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。
properties-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>
答案 0 :(得分:0)
我确实重现了这一点,这似乎是一种疏忽。对控制数据进行分组以优化输出大小,但我现在发现这可能会导致问题!
我不确定在给定当前结构的情况下可以正确推断订单。我在此添加了issue。