似乎存在与xf:triggers
中嵌入的fr:section
相关的问题,请参阅以下两个示例表单。
任何已知的解决方法?
<xh:html 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:xh="http://www.w3.org/1999/xhtml" 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:title>Test Form</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>
<message-section>
<message>my message</message>
</message-section>
</form>
</xf:instance>
<!-- Metadata -->
<xf:instance id="fr-form-metadata" xxf:exclude-result-prefixes="#all" xxf:readonly="true">
<metadata>
<application-name>test-app</application-name>
<form-name>client-js-sample</form-name>
<title xml:lang="en">Test Form</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</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">
<xf:output id="message" ref="message-section/message"/>
<xf:trigger>
<xf:label>Show</xf:label>
<xxf:script ev:event="DOMActivate" type="javascript">
var message = ORBEON.xforms.Document.getValue("message");
window.alert("message:" + message);
</xxf:script>
</xf:trigger>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
嵌入在fr:section中的只要xf:trigger
嵌入fr:section
,Orbeon JavaScript API就不再找到控件message
了。除了额外的fr:section
之外,这是相同的基本形式。
<xh:html 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:xh="http://www.w3.org/1999/xhtml" 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:title>Test Form</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>
<message-section>
<message>my message</message>
</message-section>
</form>
</xf:instance>
<!-- Metadata -->
<xf:instance id="fr-form-metadata" xxf:exclude-result-prefixes="#all" xxf:readonly="true">
<metadata>
<application-name>test-app</application-name>
<form-name>client-js-sample</form-name>
<title xml:lang="en">Test Form</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</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>
<xf:label>Test Section</xf:label>
<xf:output id="message" ref="message-section/message"/>
<xf:trigger>
<xf:label>Show</xf:label>
<xxf:script ev:event="DOMActivate" type="javascript">
var message = ORBEON.xforms.Document.getValue("message");
window.alert("message:" + message);
</xxf:script>
</xf:trigger>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
答案 0 :(得分:1)
这是因为该部分是XBL控件,当您的控件位于XBL控件内时,在生成的HTML中,容器的ID将作为控件ID的前缀添加。所以你可以使用:
var messageControl = ORBEON.jQuery('*[id $= "message"]')[0];
alert(ORBEON.xforms.Document.getValue(messageControl));
有关详情,请参阅how to use getValue()
and setValue()
on forms created with Form Builder上的文档部分。