如何将数据表 xbl 控件实现到 Orbeon Form Builder Xform

发布于 2024-10-02 01:29:52 字数 11196 浏览 0 评论 0 原文

我是 xforms 的新手 - 使用 Orbeon Form Builder 3.8 PE。我读过有关高级 xbl 控件的内容,例如“警报对话框”和“数据表”。这些在我的应用程序中非常有用,但我无法弥合我在如何实现它们方面的知识差距。

看来我需要在某处添加一个属性才能将它们放入工具箱中;或者我需要直接将代码添加到 xform 中。 Orbeon 示例显示的片段让我认为是后者/但是,这些示例脱离了上下文 - 不知道使用哪些标签来夹住这些东西,也不知道如何在稍后的操作等中引用它们。

提前致谢。 [编辑:每个评论下面的代码] 账单

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
        xmlns:exforms="http://www.exforms.org/exf/1-0"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:saxon="http://saxon.sf.net/"
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:sql="http://orbeon.org/oxf/xml/sql"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
        xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xhtml:head>
    <xhtml:title>Operations</xhtml:title>
    <xforms:model id="fr-form-model">


        <xforms:instance id="fr-form-instance">
            <form>
                <section-1>
                    <control-1/>
                    <control-2/>
                </section-1>
                <section-2/>
                    <control-3/>
            </form>
        </xforms:instance>


        <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
            <xforms:bind id="section-1-bind" nodeset="section-1">
                <xforms:bind id="control-1-bind" name="control-1" nodeset="control-1"/>
                <xforms:bind id="control-2-bind" name="control-2" nodeset="control-2"/>
            </xforms:bind>
            <xforms:bind id="section-2-bind" nodeset="section-2">
                <xforms:bind id="control-3-bind" name="control-3" nodeset="control-3"/>
            </xforms:bind>
        </xforms:bind>


        <xforms:instance id="fr-form-metadata" xxforms:readonly="true">
            <metadata>
                <application-name>KENAN_TOOLKIT</application-name>
                <form-name>operations-process</form-name>
                <title xml:lang="en">Operations</title>
                <description xml:lang="en"/>
                <author/>
                <logo mediatype="image/jpeg" filename="optimum-lightpath-logo-810x141.JPG"
                      size="14799">/fr/service/oracle/crud/orbeon/builder/data/3978eab19d9c6ccd8c65a787aa1864c4/541ca86ada859805464573ca539d6327.JPG</logo>
            </metadata>
        </xforms:instance>


        <xforms:instance id="fr-form-attachments">
            <attachments>
                <css mediatype="text/css" filename="" size=""/>
                <pdf mediatype="application/pdf" filename="" size=""/>
            </attachments>
        </xforms:instance>



        <xforms:instance id="fr-form-resources" xxforms:readonly="false">
            <resources>
                <resource xml:lang="en">
                    <section-1>
                        <label>EBF</label>
                        <help/>
                    </section-1>
                    <control-1>
                        <label/>
                        <hint/>
                        <help/>
                        <alert/>
                    </control-1>
                    <control-2>
                        <label/>
                        <hint/>
                        <help/>
                        <alert/>
                    </control-2>
                    <section-2>
                        <label>Archive</label>
                        <help/>
                    </section-2>
                    <control-3>
                        <label/>
                        <hint/>
                        <help/>
                        <alert/>
                    </control-3>
                </resource>
            </resources>
        </xforms:instance>


        <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
            <request/>
        </xforms:instance>

        <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
            <response/>
        </xforms:instance>
        <xforms:instance id="testsvc-instance" class="fr-database-service"
                         xxforms:exclude-result-prefixes="#all">
            <body>&lt;sql:config xmlns:sql="http://orbeon.org/oxf/xml/sql"&gt;
            &lt;sql:datasource&gt;orbeonedmDS&lt;/sql:datasource&gt;
&lt;sql:query&gt;SELECT n.node_id as id, n.node_name_tid as name, n.sw_ver as ver, m.model_name as model FROM techmgr.node n, techmgr.model m WHERE n.model_id = m.model_id  and rownum between 0 and 100&lt;/sql:query&gt;

        &lt;/sql:config&gt;</body>
        </xforms:instance>
        <xforms:submission id="testsvc-submission" class="fr-database-service"
                           ref="instance('fr-service-request-instance')"
                           resource="/fr/service/custom/orbeon/database"
                           method="post"
                           serialization="application/xml"
                           replace="instance"
                           instance="fr-service-response-instance"/>
        <xforms:action id="pop-test-binding">

            <xforms:action ev:event="xforms-ready" ev:observer="fr-form-model">

                <xforms:send submission="testsvc-submission"/>
            </xforms:action>

            <xforms:action ev:event="xforms-submit" ev:observer="testsvc-submission">

                <xxforms:variable name="request-instance-name" select="'testsvc-instance'" as="xs:string"/>

                <xforms:insert nodeset="instance('fr-service-request-instance')"
                               origin="saxon:parse(instance($request-instance-name))"/>


                <xforms:action context="instance('fr-service-request-instance')">

                </xforms:action>
            </xforms:action>

            <xforms:action ev:event="xforms-submit-done" ev:observer="testsvc-submission"
                           context="instance('fr-service-response-instance')">

            </xforms:action>
        </xforms:action>

    </xforms:model>
</xhtml:head>
<xhtml:body>
    <fr:view>
        <xforms:label ref="instance('fr-form-metadata')/title"/>
        <fr:body>
            <fr:section id="section-1-section" bind="section-1-bind">
                <xforms:label ref="$form-resources/section-1/label"/>
                <xforms:help ref="$form-resources/section-1/help"/>
                <fr:grid columns="2">
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:input id="control-1-control" bind="control-1-bind">
                                <xforms:label ref="$form-resources/control-1/label"/>
                                <xforms:hint ref="$form-resources/control-1/hint"/>
                                <xforms:help ref="$form-resources/control-1/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </xforms:input>
                        </xhtml:td>
                        <xhtml:td/>
                    </xhtml:tr>
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:input id="control-2-control" bind="control-2-bind">
                                <xforms:label ref="$form-resources/control-2/label"/>
                                <xforms:hint ref="$form-resources/control-2/hint"/>
                                <xforms:help ref="$form-resources/control-2/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </xforms:input>
                        </xhtml:td>
                        <xhtml:td/>
                    </xhtml:tr>

                </fr:grid>
            </fr:section>
            <fr:section id="section-2-section" bind="section-2-bind">
                <xforms:label ref="$form-resources/section-2/label"/>
                <xforms:help ref="$form-resources/section-2/help"/>
                <fr:grid columns="1">
                    <xhtml:tr>
                        <xhtml:td>
                            <fr:datatable scrollable="both" width="800px" height="500px">
                                <thead>
                                    <tr>
                                        <th fr:sortable="true" fr:resizeable="true">ID</th>
                                        <th fr:sortable="true" fr:resizeable="true">Name</th>
                                        <th fr:sortable="true" fr:resizeable="true">Version</th>
                                        <th fr:sortable="true" fr:resizeable="true">Model</th>
                                    </tr>
                                </thead>
                                <tbody>
                                 <xforms:repeat nodeset="/testsvc:response/testsvc:row"> 
                                  <tr>
                                   <td>
                                    <xf:output value=""/>
                                   </td>
                                   <td>
                                   </td>
                                   <td>
                                   </td>
                                   <td>
                                   </td>
                                  </tr>
                                 </xforms:repeat>
                                </tbody>
                           </fr:datatable>
                        </xhtml:td>
                    </xhtml:tr>
                </fr:grid>
            </fr:section>
        </fr:body>
    </fr:view>
</xhtml:body>

I am new to xforms - using Orbeon Form Builder 3.8 PE. I have read about advanced xbl controls like 'Alert Dialog' and 'Datatable'. These would be very useful in my application, but I cannot bridge my knowledge gap as to how to implement them.

It seems either I need to add a property somewhere to get them in the toolbox; or I need to directly add code to the xform. The Orbeon examples show snippets whic lead me to think it's the latter/ However, the examples are out of context - no idea which tags are used to sandwich these things or how to refer to them later in actions and such.

Thanks in advance. [EDIT: Code below per comment]
Bill

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
        xmlns:exforms="http://www.exforms.org/exf/1-0"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:saxon="http://saxon.sf.net/"
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:sql="http://orbeon.org/oxf/xml/sql"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
        xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xhtml:head>
    <xhtml:title>Operations</xhtml:title>
    <xforms:model id="fr-form-model">


        <xforms:instance id="fr-form-instance">
            <form>
                <section-1>
                    <control-1/>
                    <control-2/>
                </section-1>
                <section-2/>
                    <control-3/>
            </form>
        </xforms:instance>


        <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
            <xforms:bind id="section-1-bind" nodeset="section-1">
                <xforms:bind id="control-1-bind" name="control-1" nodeset="control-1"/>
                <xforms:bind id="control-2-bind" name="control-2" nodeset="control-2"/>
            </xforms:bind>
            <xforms:bind id="section-2-bind" nodeset="section-2">
                <xforms:bind id="control-3-bind" name="control-3" nodeset="control-3"/>
            </xforms:bind>
        </xforms:bind>


        <xforms:instance id="fr-form-metadata" xxforms:readonly="true">
            <metadata>
                <application-name>KENAN_TOOLKIT</application-name>
                <form-name>operations-process</form-name>
                <title xml:lang="en">Operations</title>
                <description xml:lang="en"/>
                <author/>
                <logo mediatype="image/jpeg" filename="optimum-lightpath-logo-810x141.JPG"
                      size="14799">/fr/service/oracle/crud/orbeon/builder/data/3978eab19d9c6ccd8c65a787aa1864c4/541ca86ada859805464573ca539d6327.JPG</logo>
            </metadata>
        </xforms:instance>


        <xforms:instance id="fr-form-attachments">
            <attachments>
                <css mediatype="text/css" filename="" size=""/>
                <pdf mediatype="application/pdf" filename="" size=""/>
            </attachments>
        </xforms:instance>



        <xforms:instance id="fr-form-resources" xxforms:readonly="false">
            <resources>
                <resource xml:lang="en">
                    <section-1>
                        <label>EBF</label>
                        <help/>
                    </section-1>
                    <control-1>
                        <label/>
                        <hint/>
                        <help/>
                        <alert/>
                    </control-1>
                    <control-2>
                        <label/>
                        <hint/>
                        <help/>
                        <alert/>
                    </control-2>
                    <section-2>
                        <label>Archive</label>
                        <help/>
                    </section-2>
                    <control-3>
                        <label/>
                        <hint/>
                        <help/>
                        <alert/>
                    </control-3>
                </resource>
            </resources>
        </xforms:instance>


        <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
            <request/>
        </xforms:instance>

        <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
            <response/>
        </xforms:instance>
        <xforms:instance id="testsvc-instance" class="fr-database-service"
                         xxforms:exclude-result-prefixes="#all">
            <body><sql:config xmlns:sql="http://orbeon.org/oxf/xml/sql">
            <sql:datasource>orbeonedmDS</sql:datasource>
<sql:query>SELECT n.node_id as id, n.node_name_tid as name, n.sw_ver as ver, m.model_name as model FROM techmgr.node n, techmgr.model m WHERE n.model_id = m.model_id  and rownum between 0 and 100</sql:query>

        </sql:config></body>
        </xforms:instance>
        <xforms:submission id="testsvc-submission" class="fr-database-service"
                           ref="instance('fr-service-request-instance')"
                           resource="/fr/service/custom/orbeon/database"
                           method="post"
                           serialization="application/xml"
                           replace="instance"
                           instance="fr-service-response-instance"/>
        <xforms:action id="pop-test-binding">

            <xforms:action ev:event="xforms-ready" ev:observer="fr-form-model">

                <xforms:send submission="testsvc-submission"/>
            </xforms:action>

            <xforms:action ev:event="xforms-submit" ev:observer="testsvc-submission">

                <xxforms:variable name="request-instance-name" select="'testsvc-instance'" as="xs:string"/>

                <xforms:insert nodeset="instance('fr-service-request-instance')"
                               origin="saxon:parse(instance($request-instance-name))"/>


                <xforms:action context="instance('fr-service-request-instance')">

                </xforms:action>
            </xforms:action>

            <xforms:action ev:event="xforms-submit-done" ev:observer="testsvc-submission"
                           context="instance('fr-service-response-instance')">

            </xforms:action>
        </xforms:action>

    </xforms:model>
</xhtml:head>
<xhtml:body>
    <fr:view>
        <xforms:label ref="instance('fr-form-metadata')/title"/>
        <fr:body>
            <fr:section id="section-1-section" bind="section-1-bind">
                <xforms:label ref="$form-resources/section-1/label"/>
                <xforms:help ref="$form-resources/section-1/help"/>
                <fr:grid columns="2">
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:input id="control-1-control" bind="control-1-bind">
                                <xforms:label ref="$form-resources/control-1/label"/>
                                <xforms:hint ref="$form-resources/control-1/hint"/>
                                <xforms:help ref="$form-resources/control-1/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </xforms:input>
                        </xhtml:td>
                        <xhtml:td/>
                    </xhtml:tr>
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:input id="control-2-control" bind="control-2-bind">
                                <xforms:label ref="$form-resources/control-2/label"/>
                                <xforms:hint ref="$form-resources/control-2/hint"/>
                                <xforms:help ref="$form-resources/control-2/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </xforms:input>
                        </xhtml:td>
                        <xhtml:td/>
                    </xhtml:tr>

                </fr:grid>
            </fr:section>
            <fr:section id="section-2-section" bind="section-2-bind">
                <xforms:label ref="$form-resources/section-2/label"/>
                <xforms:help ref="$form-resources/section-2/help"/>
                <fr:grid columns="1">
                    <xhtml:tr>
                        <xhtml:td>
                            <fr:datatable scrollable="both" width="800px" height="500px">
                                <thead>
                                    <tr>
                                        <th fr:sortable="true" fr:resizeable="true">ID</th>
                                        <th fr:sortable="true" fr:resizeable="true">Name</th>
                                        <th fr:sortable="true" fr:resizeable="true">Version</th>
                                        <th fr:sortable="true" fr:resizeable="true">Model</th>
                                    </tr>
                                </thead>
                                <tbody>
                                 <xforms:repeat nodeset="/testsvc:response/testsvc:row"> 
                                  <tr>
                                   <td>
                                    <xf:output value=""/>
                                   </td>
                                   <td>
                                   </td>
                                   <td>
                                   </td>
                                   <td>
                                   </td>
                                  </tr>
                                 </xforms:repeat>
                                </tbody>
                           </fr:datatable>
                        </xhtml:td>
                    </xhtml:tr>
                </fr:grid>
            </fr:section>
        </fr:body>
    </fr:view>
</xhtml:body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必你懂 2024-10-09 01:29:52

您可以在 wiki 上找到有关 XBL 的文档,该文档面向手动编写 XForms 以及想要使用 XBL 组件编写自己的 XBL 组件,而不是将 XBL 组件添加到 Form Builder。

话虽这么说,您当然可以将 XBL 组件添加到 Form Builder,但这需要您更改组件的源,对于某些组件,甚至可能更改 Form Builder 本身。这是“高级 Orbeon Forms 开发人员”的一项任务,但是嘿,谁说您不是其中之一,或者不会很快成为其中之一?只是给您一些提示:

  1. 添加到工具箱的 XBL 组件是从 oxf.fb.toolbox.group.* 属性引用的。默认值在 中定义properties-form-b​​uilder.xml,您可以在自己的 properties-local.xml 中覆盖它。
  2. 为了在表单生成器中可用,控件需要向表单生成器提供一些元数据。例如,请参阅如何为 简单文本字段。也许 XBL 组件最简单的示例是
  3. 如果您拥有的组件需要大量配置,则不能很好地适应表单的单个单元格(例如 数据表),或者甚至没有设计成适合一个单元格(例如警报对话框),肯定需要对 Form Builder 进行更改(也许是重大更改)。

关于在 Form Builder 中支持 Orbeon 数据表的想法

  1. 目前 Form Builder 中的所有组件都绑定到一个包含一个值的节点。即使是日期/时间控件(可以显示为 2 个字段,一个用于日期,一个用于时间),也绑定到一个包含 2010- 形式的 xs:dateTime 的节点。 11-12T10:16:36.209-08:00。对于可以容纳更丰富数据(例如数据表)的组件,我们需要超越这一单组件/单值映射。
  2. #1 中关于绑定的内容延伸到了调用服务。 Form Builder 不会对服务可以返回的 XML 进行任何限制,但是 Form Builder 可以通过从服务返回的 XML 中提取单个值(而不是子树)来设置控件的值。这也需要扩展以处理更丰富的组件,例如数据表。
  3. 第一步是支持只读数据表。为了支持读写数据表,某些单元格需要能够包含其他控件,使其更像现有的网格。

The documentation about XBL you'll find on the wiki is geared towards people who write XForms by hand, and who would like to either use XBL components or write their own XBL component, rather than add XBL components to Form Builder.

This being said, you can certainly add XBL components to Form Builder, but that will require you to change the source of the components, and for some components, maybe even change Form Builder itself. This is a task for "advanced Orbeon Forms developers", but hey, who said you aren't one, or won't become one very quickly? Just to give you a few pointers:

  1. XBL components added to the toolbox are referenced from the oxf.fb.toolbox.group.* properties. The default is defined in properties-form-builder.xml and you can override this in your own properties-local.xml.
  2. To be usable in Form Builder, controls need to provide some metadata to Form Builder. See for instance how this is done for a simple text field. And maybe the simplest example of an XBL component is the <fr:button>.
  3. If the component you have requires significant configuration, doesn't fit well into once cell of a form (e.g. datatable), or isn't even designed to fit into one cell (e.g. alert dialog), changes, maybe significant ones, to Form Builder will be for sure required.

Ideas about supporting the Orbeon datatable in Form Builder

  1. All the components we have currently in Form Builder are bound to one node that contains one value. Even a date/time control, which can show as 2 fields, one for the date and one for the time, is bound to a node which contains an xs:dateTime of the form 2010-11-12T10:16:36.209-08:00. We'll need to go beyond this one component / one value mapping for components which can hold richer data, like the datatable.
  2. What was said for binding in #1 extends to calling services. Form Builder doesn't put any restriction on what XML a service can return, but then Form Builder can just set the value of controls by extracting single values (not subtrees) from the XML returned by the service. This too will need to be extended to deal with richer components, like the datatable.
  3. A first step is to support a read-only datatable. To support read-write datatable, certain cells will need to be able to contain other controls, making it more like the existing grid.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文