0

我有一个 Orbeon 应用程序,它显示一个测试结果表,在这个表中是上传控件,使用户能够上传分析所需的数据。我设置这个表我需要xforms:upload根据我的初始化数据中的字段禁用控件。

我试图使用 AVT 在代码required="true"在实例数据中找到的任何地方调用 display:none 样式 - 但据我所知,这对 Form Runner 显示的输出没有影响。有人可以帮忙吗?

我的 XML 数据和代码如下 - 请查看xforms:upload我的问题所在位置的标记 ( display: none):

样本输出:

+------+------+---------------------+------------------------+--------+
| Test | Case |     EB Log          |     COM Log            | Status |   
+------+------+---------------------+------------------------+--------+
| 022  | 01   | Upload              |                        |        |
+------+------+---------------------+------------------------+--------+
| 022  | 02   | Upload              |                        |        |
+------+------+---------------------+------------------------+--------+
| 032  | 01   |                     | Upload                 |        |
+------+------+---------------------+------------------------+--------+
| 032  | 02   | Upload              | Upload                 |        |
+------+------+---------------------+------------------------+--------+
| 032  | 03   | Upload              |                        |        |
+------+------+---------------------+------------------------+--------+
| 032  | 04   | Upload              |                        |        |
+------+------+---------------------+------------------------+--------+

样本数据:

<test_view>
    <test id="022">
        <case id="01"><eb_log required="true" filename="" mediatype="" size=""></eb_log><com_log required="false" filename="" mediatype="" size=""></com_log><status>PASS</status></case>
        <case id="02"><eb_log required="true" filename="" mediatype="" size=""></eb_log><com_log required="false" filename="" mediatype="" size=""></com_log><status>FAIL</status></case>
    </test>
    <test id="032">
        <case id="01"><eb_log required="false" filename="" mediatype="" size=""></eb_log><com_log required="true" filename="" mediatype="" size=""></com_log><status>none</status></case>
        <case id="02"><eb_log required="true" filename="" mediatype="" size=""></eb_log><com_log required="true" filename="" mediatype="" size=""></com_log><status>none</status></case>
        <case id="03"><eb_log required="true" filename="" mediatype="" size=""></eb_log><com_log required="false" filename="" mediatype="" size=""></com_log><status>Run</status></case>
        <case id="04"><eb_log required="true" filename="" mediatype="" size=""></eb_log><com_log required="false" filename="" mediatype="" size=""></com_log><status>Run</status></case>
    </test>
</test_view>

测试代码:

<xhtml:html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
    <xhtml:head>
        <xhtml:title>XForms Log Analyser</xhtml:title>

        <xforms:model>
            <!-- <xforms:instance id="tests-instance" src="test-view.xml" xmlns=""/> -->
            <!-- <xforms:submission id="tests-submission" serialization="none" method="get" resource="http://localhost:8080/orbeon/log-analyser/test-view.xml" replace="instance" instance="tests-instance"/>  -->
            <!-- <xforms:bind nodeset="instance('tests-instance')" type="xs:anyURI"/> -->

                <!-- Load tests when the XForms engine is ready -->
                <xforms:send ev:event="xforms-ready" submission="list-submission"/>

                <!-- Autosave instance data if any value changes in the instance data -->
                <xforms:send ev:event="xxforms-value-changed" ev:observer="tests-instance" submission="save-submission"/>           

                <!-- Instance that contains all the books -->
                <xforms:instance id="tests-instance">
                <swate_view>
                    <test id="">
                        <case id=""><eb_log required="" filename="" mediatype="" size=""></eb_log><com_log required="" filename="" mediatype="" size=""></com_log><status></status></case>
                    </test>
                </swate_view>
                </xforms:instance>

                <xforms:bind nodeset="instance('tests-instance')"/>

                <!-- Submission to load/reset the default data -->
                <xforms:submission id="reset-submission" serialization="none"
                    method="get" action="oxf:/apps/log-analyser/test-view.xml"
                    replace="instance" instance="tests-instance"/>

                <!-- Submission to get the document containing all the tests -->
                <xforms:submission id="list-submission" serialization="none"
                    method="get" action="/exist/rest/db/orbeon/log-analyser/tests.xml"
                    replace="instance" instance="tests-instance"/>

                <!-- Submission to save the document containing all the tests -->
                <xforms:submission id="save-submission" ref="instance('tests-instance')"
                    action="/exist/rest/db/orbeon/log-analyser/tests.xml"
                    method="put" replace="none">
                    <xforms:message ev:event="xforms-submit-error" level="modal">An error occurred while saving!</xforms:message>
                </xforms:submission>

        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <fr:datatable paginated="true" rowsPerPage="5" maxNbPagesToDisplay="7">
            <thead>
                <xhtml:tr>
                    <xhtml:th fr:sortable="true" fr:resizeable="true">Test</xhtml:th>
                    <xhtml:th fr:sortable="true" fr:resizeable="true">Case</xhtml:th>
                    <xhtml:th fr:sortable="true" fr:resizeable="true">EB Log</xhtml:th>
                    <xhtml:th fr:sortable="true" fr:resizeable="true">Com Log</xhtml:th>
                    <xhtml:th fr:sortable="true" fr:resizeable="true">Status</xhtml:th>
                </xhtml:tr>
            </thead>
            <tbody>
            <xhtml:tr repeat-nodeset="test/case">
                <xhtml:td>
                    <xforms:output ref="../@id"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:output value="@id"/>
                </xhtml:td>
                <xhtml:td> 
                    <!-- <xforms:output value="if(eb_log[@required='true']) then ('Upload') else ('-')"/> -->
                    **<xforms:upload style="{if(eb_log[@required='false']) then ('display: none')}" ref="eb_log"><xforms:filename ref="@filename"/><xforms:mediatype ref="@mediatype"/><xxforms:size ref="@size"/></xforms:upload>**
                </xhtml:td>
                <xhtml:td>
                    <!-- <xforms:output value="if(com_log[@required='true']) then ('Upload') else ('-')"/> -->
                    **<xforms:upload style="{if(com_log[@required='false']) then ('display: none')}" ref="com_log"><xforms:filename ref="@filename"/><xforms:mediatype ref="@mediatype"/><xxforms:size ref="@size"/></xforms:upload>**
                </xhtml:td>
                <xhtml:td>
                    <xforms:output ref="status/text()"/>
                </xhtml:td>
            </xhtml:tr>
            </tbody>
        </fr:datatable>
        <xforms:submit submission="save-submission">
            <xforms:label>Save</xforms:label>
        </xforms:submit>
        <xforms:submit submission="reset-submission">
            <xforms:label>Reset</xforms:label>
        </xforms:submit>
    </xhtml:body>
</xhtml:html>
4

2 回答 2

1

一个常见的技巧是使用该ref属性并在其上放置一个条件。因此,您的上传将如下所示:

<xforms:upload ref="com_log[@required = 'false']" ...>

这是有效的,因为如果条件是false,则ref属性指向空序列。并且具有指向空序列的绑定的控件会自动变得不相关。

于 2012-10-19T17:55:39.923 回答
0

下面的片段似乎在我的表中工作(首先删除了我在xforms:upload标签中定义的样式),因为我已经在利用 Yahoo!Form Runner 中的 UI 库。

我仍然很想知道是否有官方方法可以禁用xforms:upload控件的显示。

<xhtml:td class="if{(eb_log[@required='false']) then 'yui-dt-hidden' else ''}">
于 2012-10-19T10:36:08.430 回答