问题描述
我正在使用 Orbeon 的 JS 嵌入 API。当我有一个 fr:yesno
控件的可见性取决于另一个 yesno 值时,我遇到了一个错误,迫使我刷新网站。错误显示在 orbeon 的对话框中,浏览器控制台为空。
产生的错误是:
Exception in client-side code.
* Message: TypeError: _.detect is not a function
导致问题的具体公式为:
<xf:bind id="control-2-bind" ref="control-2" name="control-2" type="xs:boolean"
relevant="$control-1/string() = 'true'"
required="true()"/>
...
<fr:yesno-input bind="control-1-bind" ...>
<fr:yesno-input bind="control-2-bind" ...>
另一方面,这没有问题:
<xf:bind id="control-6-bind" ref="control-6" name="control-6"
relevant="$control-5/string() = 'false'"/>
...
<fr:yesno-input bind="control-5-bind" ...>
<fr:explanation bind="control-6-bind" ...>
我曾尝试在可见性公式中使用 xxf:is-control-relevant('control-2-control')
函数逐步构建 relevant
属性(以实现传递不可见性),但它没有按预期工作,因为该函数似乎返回更改相关 yesno 值时的旧值。
我的问题是:如何在使用 JS 嵌入时修复错误?
完整的表单定义来复制
<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:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
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"
fr:data-format-version="4.0.0">
<xh:head>
<xh:title>JavaScript Embedding</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true" xxf:analysis.calculate="true">
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
<form>
<section-1>
<grid-1>
<control-1/>
<control-2/>
<control-3/>
<control-5/>
<control-6/>
</grid-1>
</section-1>
</form>
</xf:instance>
<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="grid-1-bind" ref="grid-1" name="grid-1">
<xf:bind id="control-1-bind" ref="control-1" name="control-1" type="xs:boolean"
required="true()"/>
<xf:bind id="control-2-bind" ref="control-2" name="control-2" type="xs:boolean"
relevant="$control-1/string() = 'true'"
required="true()"/>
<xf:bind id="control-3-bind" ref="control-3" name="control-3" type="xs:decimal"
relevant="$control-1/string() = 'true' and $control-2/string() = 'true'"
required="true()"/>
<xf:bind id="control-5-bind" ref="control-5" name="control-5" type="xs:boolean"
required="true()"/>
<xf:bind id="control-6-bind" ref="control-6" name="control-6"
relevant="$control-5/string() = 'false'"/>
</xf:bind>
</xf:bind>
</xf:bind>
<xf:instance id="fr-form-Metadata" xxf:readonly="true" xxf:exclude-result-prefixes="#all">
<Metadata>
<application-name>Test</application-name>
<form-name>EmbedJS</form-name>
<title xml:lang="en">JavaScript Embedding</title>
<description xml:lang="en"/>
<created-with-version>2020.1.202012300129 PE</created-with-version>
<updated-with-version>2020.1.202012300129 PE</updated-with-version>
</Metadata>
</xf:instance>
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments/>
</xf:instance>
<xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<control-1>
<label>Select yes</label>
<hint/>
</control-1>
<control-2>
<label>Select yes again</label>
<hint/>
</control-2>
<control-3>
<label>Input number</label>
<hint/>
</control-3>
<control-5>
<label>But not Now</label>
<hint/>
</control-5>
<control-6>
<text xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:p="http://www.orbeon.com/oxf/pipeline"><div>Some text</div></text>
</control-6>
<section-1>
<label>Foo</label>
</section-1>
</resource>
</resources>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<fr:section id="section-1-section" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid id="grid-1-grid" bind="grid-1-bind">
<fr:c y="1" x="1" w="12">
<fr:yesno-input xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
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"/>
</fr:yesno-input>
</fr:c>
<fr:c x="1" y="2" w="12">
<fr:yesno-input xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
id="control-2-control"
bind="control-2-bind">
<xf:label ref="$form-resources/control-2/label"/>
<xf:hint ref="$form-resources/control-2/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</fr:yesno-input>
</fr:c>
<fr:c x="1" y="3" w="12">
<fr:number xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:NumberSupport="java:org.orbeon.xbl.NumberSupportJava"
id="control-3-control"
bind="control-3-bind">
<xf:label ref="$form-resources/control-3/label"/>
<xf:hint ref="$form-resources/control-3/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</fr:number>
</fr:c>
<fr:c x="1" y="4" w="12">
<fr:yesno-input xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
id="control-5-control"
bind="control-5-bind">
<xf:label ref="$form-resources/control-5/label"/>
<xf:hint ref="$form-resources/control-5/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</fr:yesno-input>
</fr:c>
<fr:c x="1" y="5" w="12">
<fr:explanation xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" id="control-6-control"
bind="control-6-bind">
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<fr:text ref="$form-resources/control-6/text" mediatype="text/html"/>
</fr:explanation>
</fr:c>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
orbeon.log
太长:
https://pastebin.pl/view/8f6e652d
我如何使用嵌入:
<script>
function embedForm() {
ORBEON.fr.API.embedForm(
document.getElementById("formEmbedder"),"/orbeon","Test","EmbedJS","new"
);
}
embedForm();
</script>
</body>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)