0

我正在尝试使用添加按钮在运行/运行时添加一个重复元素。当我单击添加按钮时,我收到错误“功能索引使用不在范围内的重复 id 'employee-repeat'”。我不确定我是否在表单中正确引用了重复元素。这是完整的 x 来自 。

      `<xhtml:html xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
        xmlns:saxon="http://saxon.sf.net/"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
        xmlns:sql="http://orbeon.org/oxf/xml/sql"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:exforms="http://www.exforms.org/exf/1-0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:ev="http://www.w3.org/2001/xml-events">
<xhtml:head>
    <xhtml:title>U Form</xhtml:title>
    <xforms:model id="fr-form-model">
       <xforms:instance id="fr-form-instance">
            <form>
                <section-1>
                    <hello/>
                </section-1>
            </form>
        </xforms:instance>


        <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
            <xforms:bind id="section-1-bind" nodeset="section-1">
                <xforms:bind id="hello-bind" nodeset="hello" name="hello"/>
            </xforms:bind>
        </xforms:bind>


        <xforms:instance id="fr-form-metadata" xxforms:readonly="true">
            <metadata>
                <application-name>gvhd</application-name>
                <form-name>test</form-name>
                <title xml:lang="en">Untitled Form</title>
                <description xml:lang="en"/>
                <author/>
                <logo mediatype="" filename="" size=""/>
            </metadata>
        </xforms:instance>


        <xforms:instance id="fr-form-attachments">
            <attachments>
                <css mediatype="text/css" filename="" size=""/>
                <pdf mediatype="application/pdf" filename="" size=""/>
            </attachments>
        </xforms:instance>


        <xforms:instance id="fr-form-resources" xxforms:readonly="true">
            <resources>
                <resource xml:lang="en">
                    <section-1>
                        <label>Section1</label>
                        <help/>
                    </section-1>
                    <hello>
                        <label>hello</label>
                        <hint/>
                        <help/>
                        <alert/>
                    </hello>
                </resource>
            </resources>
        </xforms:instance>

        <xforms:instance id="employees-instance">
            <employees>
                <employee>
                    <first-name>Alice</first-name>
                </employee>
                <employee>
                    <first-name>Bob</first-name>
                </employee>
                <employee>
                    <first-name>Marie</first-name>
                </employee>
            </employees>
        </xforms:instance>


        <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
            <request/>
        </xforms:instance>

        <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
            <response/>
        </xforms:instance>

    </xforms:model>
</xhtml:head>
<xhtml:body>
    <fr:view>
        <xforms:label ref="instance('fr-form-metadata')/title"/>
        <fr:body>
            <fr:section id="section-1-section" bind="section-1-bind">
                <xforms:label ref="$form-resources/section-1/label"/>
                <xforms:help ref="$form-resources/section-1/help"/>
                <fr:grid columns="2">
                    <xforms:repeat nodeset="instance('employees-instance')/employee" id="employee-repeat">
                              <xhtml:tr>
                            <xhtml:td>
                                <xforms:output ref="first-name"/>
                            </xhtml:td>
                            <xhtml:td>
                                <xforms:output ref="first-name"/>
                            </xhtml:td>
                        </xhtml:tr>
                                                  </xforms:repeat>
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:input bind="hello-bind" id="hello-control">
                                <xforms:label ref="$form-resources/hello/label"/>
                                <xforms:hint ref="$form-resources/hello/hint"/>
                                <xforms:help ref="$form-resources/hello/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </xforms:input>
                        </xhtml:td>
                        <xhtml:td/>
                    </xhtml:tr>
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:trigger>
                                <xforms:label>Add</xforms:label>
                                <xforms:insert ev:event="DOMActivate" context="instance('fr-form-instance')" nodeset="instance('employees-instance')/employee" at="index('employee-repeat')"
                                               position="after"/>
                            </xforms:trigger>
                        </xhtml:td>
                        <xhtml:td/>
                    </xhtml:tr>
                </fr:grid>
            </fr:section>
        </fr:body>
    </fr:view>
</xhtml:body>

`

4

3 回答 3

0

我已在 Orbeon Sandbox 中运行此代码,但无法重现上述错误。我几乎没有与未声明的变量相关的错误,一旦我声明了变量,表单就会正常呈现,并且我能够添加新行。

但是,从技术上讲,我看到您index('employee-repeat')在重复循环之外的 Add 触发器中使用了重复索引,因此您可能遇到了该错误。为了更好地提供帮助,请告诉我您是如何运行这些表单的。

更新:根据 OP 评论,这里是更新。

它很容易纠正它。你不应该使用index('employee-repeat').

  1. 如果您想在上次使用时添加新行at=last()

  2. 如果您想在第一次使用时添加at=1

  3. 如果您想在中间添加(您想要的位置),然后将Add链接移动到重复中,对于每一行,您将拥有 Add在所需位置添加新行的链接。
于 2012-09-18T09:08:33.580 回答
0

您的示例似乎适用于最新的 Orbeon Forms 代码。它运行没有错误,并且“Marie Marie”在按下添加按钮时被添加。你用Orbeon Forms 4.0 M10试过了吗?

(请注意,4.0 M10 是一个里程碑版本,它还不是 4.0 最终版本。)

于 2012-09-19T06:29:14.317 回答
0

根据原始 XF 1.1 建议 Kaipa M Sarma 先生的陈述是正确的,一旦您决定在重复控件之外使用触发按钮,请提及相应的索引,如 last() 或 index = 1 。否则,如果您需要在中间或任何位置插入,您决定在重复中使用按钮 ..

于 2012-09-20T06:50:34.713 回答