在提交操作中将输入控件中的参数添加到url

时间:2016-06-08 09:52:42

标签: html xquery xforms exist-db

我试图将参数从我的输入文本控件传递到被调用的xquery,方法是将它们作为参数添加到url中。我尝试过各种各样的方式 - 总是没有成功。你能看看我告诉我我做错了吗?

xquery version "3.0";

declare option exist:serialize "method=xhtml media-type=application/xhtml+xml indent=yes";

import module namespace xmldb="http://exist-db.org/xquery/xmldb";

declare variable $collection as xs:string := '/db/junitReports';

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:bf="http://betterform.sourceforge.net/xforms" xmlns:xf="http://www.w3.org/2002/xforms" bf:toaster-position="tl-down">
    <head>
        <title>IB interfaces regression testing report</title>
        <meta name="author" content="test"/>
        <meta name="author" content="test"/>
        <meta name="description" content="IB interfaces regression testing report"/>
        <link rel="stylesheet" type="text/css" href="styles/demo.css"/>

        <!-- INPUT CONTROLS -->
        <xf:model>
            <xf:instance id="default">
                <data xmlns="">
                    <InterfaceName constraint="true" readonly="false" required="false" relevant="true">
                    </InterfaceName>
                    <trigger1 constraint="true" readonly="false" required="false" relevant="true">
                    </trigger1>
                </data> 
            </xf:instance>

            <xf:instance id="table" xmlns="">
                <data>
                </data>
            </xf:instance>

            <xf:bind nodeset="InterfaceName" type="string">
            </xf:bind>

            <xf:submission id="showTable"
                        method="post" 
                        action="{concat('/exist/rest/db/xquery/returnTable.xq?interface=',InterfaceName)}"
                        replace="instance"
                        ref="instance('table')"
                        instance="table">
            </xf:submission>
        </xf:model>
    </head>


    <body class="soria" style="margin:30px;">
        <div class="Headline">IB test report</div>
        <div class="description">
            <p>You can restrict report output:</p>
        </div>    
        <p>2. By typing in particular interface name</p>
        <div class="Interface">
            <xf:input id="InterfaceName" ref="InterfaceName" incremental="false">
                <xf:label></xf:label>
                <xf:hint>(S|R)xxxxxYYYZZZ</xf:hint>
                <xf:help>Enter interface name</xf:help>
                <xf:alert>Enter interface name</xf:alert>
            </xf:input>
        </div>
        <br/>
        <div>
            <xf:trigger id="trigger1" ref="trigger1" incremental="true">
                <xf:label>Filter output</xf:label>
                <xf:hint>a Hint for this control</xf:hint>
                <xf:help>help for trigger1</xf:help>
                <xf:action ev:event="DOMActivate">
                    <xf:send submission="showTable"/>
                </xf:action>
            </xf:trigger>
        </div>


        <div>
            <table border="1">
                <thead>
                    <tr>
                        <th>Inteface Name</th>
                        <th>Test Date</th>
                        <th>Test Result</th>
                        <th>Report Link</th>
                    </tr>
                </thead>
                <tbody xf:repeat-nodeset="instance('table')//result">
                   <tr>
                        <td>
                            <xf:output ref="interfaceName"></xf:output>   
                        </td>
                        <td>
                            <xf:output ref="reportDate"></xf:output> 
                        </td>
                        <td>
                            <xf:output ref="testResult"></xf:output>  
                        </td>
                        <td>
                            <li>
                                <xf:output ref="fileLink"></xf:output>
                            </li>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <label>{InterfaceName}</label>
    </body>
</html>

我的uri仍然没有参数:

"resource-uri":"http://localhost:8080/exist/rest/db/xquery/returnTable.xq?interface=" 

1 个答案:

答案 0 :(得分:0)

正确的方法是在提交中用action元素替换action属性:

<xf:resource value="concat('/exist/rest/db/xquery/returnTable.xq?interface=',instance('defaultInstance')//InterfaceName,'&amp;','date=',instance('defaultInstance')//CalendarDate)"/> 
相关问题