有什么办法可以避免 Orbeon Form Builder 确实执行表单代码中的事件?
Is there any way to avoid that the Orbeon Form Builder does executes the events in the form code?
此问题与 Whosebug 中的上一个问题相关,其中建议使用事件在元素之间创建相关依赖关系。
一个代码示例,其中一节有一个问题:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:saxon="http://saxon.sf.net/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<xh:head>
<xh:meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<xh:title>Whosebug</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<xf:instance id="fr-form-metadata" xxf:exclude-result-prefixes="#all" xxf:readonly="true">
<metadata>
<application-name>WebForms</application-name>
<form-name>Whosebug_v1</form-name>
<title xml:lang="en">Whosebug</title>
<description xml:lang="en">Version: 1. Modification date: 2015-06-10 10:18:18. Publication date: 2015-06-10 10:18:18.</description>
</metadata>
</xf:instance>
<xf:instance id="fr-form-instance">
<form>
<Category>
<Question/>
</Category>
</form>
</xf:instance>
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="Category-bind" name="Category" ref="/form/Category">
<xf:bind id="Question-bind" name="Question" ref="Question" required="true()"/>
</xf:bind>
</xf:bind>
<xf:instance id="fr-form-attachments">
<attachments>
<css filename="" mediatype="text/css" size=""/>
<pdf filename="" mediatype="application/pdf" size=""/>
</attachments>
</xf:instance>
<xf:instance id="fr-form-resources" xxf:readonly="false">
<resources>
<resource xml:lang="en">
<Category>
<label><![CDATA[Category]]></label>
<hint/>
<alert/>
<Question>
<label><![CDATA[Question]]></label>
<hint/>
<alert/>
<item>
<label><![CDATA[Answer]]></label>
<hint/>
<value><![CDATA[Answer]]></value>
</item>
<item>
<label><![CDATA[Answer2]]></label>
<hint/>
<value><![CDATA[Answer2]]></value>
</item>
</Question>
</Category>
</resource>
</resources>
</xf:instance>
<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>
<!-- Keep track of visible/hidden status -->
<xf:instance id="visible">
<var>
<Category>0</Category>
<Question>false</Question>
</var>
</xf:instance>
<!-- Change the visibility status for 'Question2'. -->
<xf:setvalue event="xforms-enabled" observer="Question-control" ref="instance('visible')/Question" value="'true'"/>
<xf:setvalue event="xforms-disabled" observer="Question-control" ref="instance('visible')/Question" value="'false'"/>
<!-- Update category showed elements count for 'Question2'. -->
<xf:setvalue event="xforms-enabled" observer="Question-control" ref="instance('visible')/Category" value="instance('visible')/Category + 1"/>
<xf:setvalue event="xforms-disabled" observer="Question-control" ref="instance('visible')/Category" value="instance('visible')/Category - 1"/>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" 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 bind="Category-bind" class="webforms-element webforms-category" id="Category-control">
<xf:label mediatype="text/html" ref="instance('fr-form-resources')/resource/Category/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/alert"/>
<xh:tr>
<xh:td>
<xf:select1 appearance="full" bind="Question-bind" class="webforms-element webforms-question" id="Question-control">
<xf:label mediatype="text/html" ref="instance('fr-form-resources')/resource/Category/Question/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Question/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Question/alert"/>
<xf:itemset class="webforms-element webforms-answer" ref="instance('fr-form-resources')/resource/Category/Question/item">
<xf:label ref="label"/>
<xf:value ref="value"/>
<xf:hint ref="hint"/>
</xf:itemset>
</xf:select1>
</xh:td>
</xh:tr>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
如上一篇post所述,有两个事件可以保存问题的状态(是否可见),我添加了一个额外的事件来计算有多少元素可见类别。重要的代码在这里:
<xf:instance id="visible">
<var>
<Category>0</Category>
<Question>false</Question>
</var>
</xf:instance>
如果我将整个示例粘贴到 Orbeon 构建器版本 4.9 中,然后使用源代码编辑器再次打开它,代码将更改为:
<xf:instance id="visible">
<var>
<Category>1</Category>
<Question>true</Question>
</var>
</xf:instance>
Orbeon Builder 似乎只是通过粘贴代码来运行事件和修改变量值,并在设计器中显示结果。因此,当保存到数据库中并发布表单时,这个变量的最终值是最后一个。特别是我每次编辑源码加一的category计数器!
我假设这不是 Form Builder 中的预期行为(但它在 Form Runner 中),因此问题是:
我可以禁用表单生成器中事件的执行吗?
事实证明这是 Orbeon Forms 4.8 中引入的 Form Builder 的回归。 Issue #2261 现已修复。
此问题与 Whosebug 中的上一个问题相关,其中建议使用事件在元素之间创建相关依赖关系。
一个代码示例,其中一节有一个问题:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:saxon="http://saxon.sf.net/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<xh:head>
<xh:meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<xh:title>Whosebug</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<xf:instance id="fr-form-metadata" xxf:exclude-result-prefixes="#all" xxf:readonly="true">
<metadata>
<application-name>WebForms</application-name>
<form-name>Whosebug_v1</form-name>
<title xml:lang="en">Whosebug</title>
<description xml:lang="en">Version: 1. Modification date: 2015-06-10 10:18:18. Publication date: 2015-06-10 10:18:18.</description>
</metadata>
</xf:instance>
<xf:instance id="fr-form-instance">
<form>
<Category>
<Question/>
</Category>
</form>
</xf:instance>
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="Category-bind" name="Category" ref="/form/Category">
<xf:bind id="Question-bind" name="Question" ref="Question" required="true()"/>
</xf:bind>
</xf:bind>
<xf:instance id="fr-form-attachments">
<attachments>
<css filename="" mediatype="text/css" size=""/>
<pdf filename="" mediatype="application/pdf" size=""/>
</attachments>
</xf:instance>
<xf:instance id="fr-form-resources" xxf:readonly="false">
<resources>
<resource xml:lang="en">
<Category>
<label><![CDATA[Category]]></label>
<hint/>
<alert/>
<Question>
<label><![CDATA[Question]]></label>
<hint/>
<alert/>
<item>
<label><![CDATA[Answer]]></label>
<hint/>
<value><![CDATA[Answer]]></value>
</item>
<item>
<label><![CDATA[Answer2]]></label>
<hint/>
<value><![CDATA[Answer2]]></value>
</item>
</Question>
</Category>
</resource>
</resources>
</xf:instance>
<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>
<!-- Keep track of visible/hidden status -->
<xf:instance id="visible">
<var>
<Category>0</Category>
<Question>false</Question>
</var>
</xf:instance>
<!-- Change the visibility status for 'Question2'. -->
<xf:setvalue event="xforms-enabled" observer="Question-control" ref="instance('visible')/Question" value="'true'"/>
<xf:setvalue event="xforms-disabled" observer="Question-control" ref="instance('visible')/Question" value="'false'"/>
<!-- Update category showed elements count for 'Question2'. -->
<xf:setvalue event="xforms-enabled" observer="Question-control" ref="instance('visible')/Category" value="instance('visible')/Category + 1"/>
<xf:setvalue event="xforms-disabled" observer="Question-control" ref="instance('visible')/Category" value="instance('visible')/Category - 1"/>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" 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 bind="Category-bind" class="webforms-element webforms-category" id="Category-control">
<xf:label mediatype="text/html" ref="instance('fr-form-resources')/resource/Category/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/alert"/>
<xh:tr>
<xh:td>
<xf:select1 appearance="full" bind="Question-bind" class="webforms-element webforms-question" id="Question-control">
<xf:label mediatype="text/html" ref="instance('fr-form-resources')/resource/Category/Question/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Question/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Question/alert"/>
<xf:itemset class="webforms-element webforms-answer" ref="instance('fr-form-resources')/resource/Category/Question/item">
<xf:label ref="label"/>
<xf:value ref="value"/>
<xf:hint ref="hint"/>
</xf:itemset>
</xf:select1>
</xh:td>
</xh:tr>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
如上一篇post所述,有两个事件可以保存问题的状态(是否可见),我添加了一个额外的事件来计算有多少元素可见类别。重要的代码在这里:
<xf:instance id="visible">
<var>
<Category>0</Category>
<Question>false</Question>
</var>
</xf:instance>
如果我将整个示例粘贴到 Orbeon 构建器版本 4.9 中,然后使用源代码编辑器再次打开它,代码将更改为:
<xf:instance id="visible">
<var>
<Category>1</Category>
<Question>true</Question>
</var>
</xf:instance>
Orbeon Builder 似乎只是通过粘贴代码来运行事件和修改变量值,并在设计器中显示结果。因此,当保存到数据库中并发布表单时,这个变量的最终值是最后一个。特别是我每次编辑源码加一的category计数器!
我假设这不是 Form Builder 中的预期行为(但它在 Form Runner 中),因此问题是: 我可以禁用表单生成器中事件的执行吗?
事实证明这是 Orbeon Forms 4.8 中引入的 Form Builder 的回归。 Issue #2261 现已修复。