[形式建設者]XF:調度操作不會對庫組件控制
確定因工作問題,所以這也成爲了兩個問題想獲得一些示例代碼工作。
我有一個表單,它有一個掛鉤在password-check
事件上的Password
控件上的動作,以運行一些自定義動作和提交事件,該事件被分派到該控件。表單構建器提交按鈕已配置了自定義操作,其中之一是將password-check
事件分派給Password
控件。這一切都有效。
由於需要創建多個表單,並對其進行相同的控制,因此我想將包含Password
控件及其關聯操作和提交的部分移至部分庫。我已將該部分移至應用程序的部分庫中,並使用部分模板重建了表單。
已發佈的表單包含所需的提交和操作,但調度的事件未達到控制權(在調試日誌中,我可以看到正在運行的自定義操作和正在分派的事件,但不會(?)找到控制(見下文):
2016-03-15 12:07:10,439 DEBUG XFormsServer - process: combining with then {action: "ActionNode(xf:dispatch,Map(Some(name) -> password-check, Some(targetid) -> Password-control))"}
2016-03-15 12:07:10,439 DEBUG XFormsServer - start process: running action {action: "ActionNode(xf:dispatch,Map(Some(name) -> password-check, Some(targetid) -> Password-control))"}
2016-03-15 12:07:10,439 DEBUG XFormsServer - end process: running action {time (ms): "0", result: "success"}
(相對於下文):
2016-03-15 12:09:26,385 DEBUG XFormsServer - start process: running action {action: "ActionNode(xf:dispatch,Map(Some(name) -> password-check, Some(targetid) -> Password-control))"}
2016-03-15 12:09:26,386 DEBUG XFormsServer - start dispatching {name: "password-check", target: "SignOff-control≡xf-637≡Password-control"}
2016-03-15 12:09:26,386 DEBUG XFormsServer - start handler {name: "password-check", phase: "target", observer: "SignOff-control≡xf-637≡Password-control"}
2016-03-15 12:09:26,386 DEBUG XFormsServer - interpreter - start executing {action name: "xf:action"}
2016-03-15 12:09:26,386 DEBUG XFormsServer - interpreter - start executing {action name: "xxf:script"}
要在這個問題的一些源代碼,我創建了一個形式和圖書館只用Password
控制(和測試b utton),但注意到這些操作未包含在已發佈的表單(form1)中。
所以主要問題是如果Password
控件位於庫的包含部分中,如何將事件分派到Password
控件?
子問題是爲什麼不包含在發佈的form1版本中的操作?我看到"Actions involving controls in a given section are automatically included with the section template, along with the services called by the actions.",我認爲以下示例代碼就是這種情況。
屬性 - local.xml中
<property as="xs:string" name="oxf.fr.detail.buttons.TEST.*">
cancel
submit
</property>
<property as="xs:string" name="oxf.fr.detail.process.submit.TEST.*">
xf:dispatch(name = "password-validate", targetid = "field-control")
then require-valid
then xf:send("StoreDocument-submission")
</property>
TEST /庫
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:exf="http://www.exforms.org/exf/1-0">
<xh:head>
<xh:title>Test Library</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>
<Section>
<field/>
<button/>
</Section>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="Section-bind" name="Section" ref="Section">
<xf:bind id="field-bind" name="field" ref="field"/>
<xf:bind id="button-bind" ref="button" name="button"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>TEST</application-name>
<form-name>library</form-name>
<title xml:lang="en">Test Library</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<Section>
<label>Section</label>
</Section>
<field>
<label/>
<hint/>
</field>
<button>
<label>Button</label>
<hint/>
</button>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<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>
<xf:action id="field-revalidate" ev:event="password-check" ev:observer="field-control">
<xxf:script>
console.log('running revalidate');
</xxf:script>
</xf:action>
<xf:action id="button-action" ev:event="DOMActivate" ev:observer="button-control">
<xf:dispatch name="password-check" targetid="field-control"/>
</xf:action>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="Section-control" bind="Section-bind">
<xf:label ref="$form-resources/Section/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:input id="field-control" bind="field-bind">
<xf:label ref="$form-resources/field/label"/>
<xf:hint ref="$form-resources/field/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:trigger id="button-control" bind="button-bind">
<xf:label ref="$form-resources/button/label"/>
<xf:hint ref="$form-resources/button/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:trigger>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
TEST/Form1中
<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: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">
<xh:head>
<xh:title>Form 1</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>
<Section>
<field/>
<button/>
</Section>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="Section-bind" ref="Section" name="Section"/>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>TEST</application-name>
<form-name>form1</form-name>
<title xml:lang="en">Untitled Form</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<Section>
<label>Section</label>
<help/>
</Section>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<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>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="Section-control" bind="Section-bind">
<xf:label ref="$form-resources/Section/label"/>
<component:Section xmlns:component="http://orbeon.org/oxf/xml/form-builder/component/TEST/library"
xmlns="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:fbf="java:org.orbeon.oxf.fb.FormBuilder"/>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
我並不感到驚訝的是,'密碼check'事件沒有達到你的控制時的控制是一款模板中,作爲部分模板功能創建和XBL組件適合你,它屏蔽來自控件「外部世界」,反之亦然。 「誰」將該事件分派到密碼字段? – avernet
當用戶通過使用提交按鈕' xf:dispatch(name =」password-validate「,targetid =」field-control「)...' –
bytesnz
明白了,謝謝您的詳細信息,我已在下面發佈了答案。 – avernet