【问题标题】:Orbeon Runner - Calculated valueOrbeon Runner - 计算值
【发布时间】:2013-04-19 12:36:44
【问题描述】:

我制作了一个带有一些文本输出控件的表单,这些控件具有由其他一些具有计算值的控件计算的值。问题是,在测试模式下(来自构建器),这些控件正常工作。在 runner 中,这些控件始终为 0(空)。保存文档并再次打开后,值正确,但不刷新。

这是我的实例:

<xforms:instance id="fr-form-instance">
    <form>
        <section-1>
            <first>
                <first_amount/>
                <first_percent/>
                <first_total/>
            </first>
            <second>
                <second_amount/>
                <second_percent/>
                <second_total/>
            </second>
            <third>
                <third_amount/>
                <third_percent/>
                <third_total/>
            </third>
            <total/>
            <average/>
        </section-1>
    </form>
</xforms:instance>

还有我的绑定:

<xforms:bind xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" id="fr-form-binds"
             nodeset="instance('fr-form-instance')">
    <xforms:bind id="section-1-bind" name="section-1" ref="section-1">
        <xf:bind name="first" id="first-bind" ref="first">
            <xf:bind name="first_amount" id="first_amount-bind" ref="first_amount"
                     type="xf:decimal"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="first_percent"
                     id="first_percent-bind"
                     ref="first_percent"
                     type="xf:decimal"
                     constraint="./text()&gt;=0 or string-length(./text())=0"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="first_total"
                     id="first_total-bind"
                     ref="first_total"
                     calculate="(../first_amount/text() * ../first_percent/text()) div 100"
                     type="xf:decimal"/>
        </xf:bind>
        <xf:bind name="second" id="second-bind" ref="second">
            <xf:bind name="second_amount" id="second_amount-bind" ref="second_amount"
                     type="xf:decimal"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="second_percent"
                     id="second_percent-bind"
                     ref="second_percent"
                     type="xf:decimal"
                     constraint="./text()&gt;=0 or string-length(./text())=0"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="second_total"
                     id="second_total-bind"
                     ref="second_total"
                     calculate="(../second_amount/text() * ../second_percent/text()) div 100"
                     type="xf:decimal"/>
        </xf:bind>
        <xf:bind name="third" id="third-bind" ref="third">
            <xf:bind name="third_amount" id="third_amount-bind" ref="third_amount"
                     type="xf:decimal"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="third_percent"
                     id="third_percent-bind"
                     ref="third_percent"
                     type="xf:decimal"
                     constraint="./text()&gt;=0 or string-length(./text())=0"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="third_total"
                     id="third_total-bind"
                     ref="third_total"
                     calculate="(../third_amount/text() * ../third_percent/text()) div 100"
                     type="xf:decimal"/>
        </xf:bind>
        <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="total"
                 id="total-bind"
                 ref="total"
                 calculate="sum(instance('fr-form-instance')/section-1/first/first_total/text()) + sum(instance('fr-form-instance')/section-1/second/second_total/text()) + sum(instance('fr-form-instance')/section-1/third/third_total/text())"
                 type="xf:decimal"/>
        <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="average"
                 id="average-bind"
                 ref="average"
                 type="xf:decimal"
                 calculate="instance('fr-form-instance')/section-1/total/text() div (count(instance('fr-form-instance')/section-1/first) + count(instance('fr-form-instance')/section-1/second) + count(instance('fr-form-instance')/section-1/third))"/>
    </xforms:bind>
</xforms:bind>

【问题讨论】:

  • 你能提供一份完整的工作表格吗?请随时通过 orbeon.com 的 ebruchez 直接将其发送给我。另外,什么版本的 Orbeon Forms?

标签: orbeon


【解决方案1】:

这似乎适用于我提供的表单,无论是在测试模式下还是在部署表单时(参见屏幕截图)。我正在使用 Orbeon Forms 4.1。

没关系,但这里有几个关于 XPath 表达式的 cmets:

  • XPath 中几乎不需要text(),您可以删除表达式中所有出现的/text()
  • 您可以使用ge 运算符代替&amp;gt;=,这样更易​​读

.

【讨论】:

  • 谢谢。似乎这只发生在我的应用程序代理中。
猜你喜欢
  • 2019-02-11
  • 1970-01-01
  • 1970-01-01
  • 2020-12-21
  • 1970-01-01
  • 2021-04-27
  • 1970-01-01
  • 2015-07-13
  • 1970-01-01
相关资源
最近更新 更多