首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >eXist-db XForms提交后实例更新

eXist-db XForms提交后实例更新
EN

Stack Overflow用户
提问于 2015-07-19 16:31:48
回答 1查看 152关注 0票数 0

我为post request testig做了一个简单的测试表单。

我的简单目标是:发送带有两个参数的POST请求,将服务器响应存储在实例中(服务器只是将收到的参数原封不动地发送回表单)

代码语言:javascript
复制
 <xf:model>
        <xf:instance id="request" xmlns="">
            <data>
                <arg1>param1</arg1>
                <arg2>param2</arg2>
            </data>
        </xf:instance>

        <xf:instance id="response" xmlns="">
           <null/>
        </xf:instance>

        <xf:submission id="post-instance"
                        method="put" 
                        replace="all"
                        instance="response"
                        resource="adderPost.xq"
                        ref="instance('request')"
                        serialization="application/xml"
                        mediatype="application/xml"
                        includenamespaceprefixes=""
                        >
        </xf:submission>
  </xf:model>

</head>
<body>
    <h1>XForm interaction with XQuery</h1>
    <xf:input ref="instance('request')/arg1" incremental="true">
        <xf:label>Arg1:</xf:label>
    </xf:input>
    <br/>
    <xf:input ref="instance('request')/arg2" incremental="true">
        <xf:label>Arg2:</xf:label>
    </xf:input>
    <br/>
    <xf:output ref="instance('response')/result">
        <xf:label> Response:</xf:label>
    </xf:output>
    <br/>

    <xf:submit submission="post-instance">
        <xf:label>Post</xf:label>
    </xf:submit>
    <p id="status"></p>
</body>

如果我使用参数replace="all",如上面的代码所示,服务器将返回答案:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <arg1>param1</arg1>
    <arg2>param2</arg2>
</result>

但是,如果我使用参数replace="instance“instance="response”

这种情况会发生:

代码语言:javascript
复制
    throw 'allowScriptTagRemoting is false.';
    (function(){
    var r=window.dwr._[0];
    //#DWR-INSERT
    //#DWR-REPLY
    r.handleCallback("2","0",[{bubbles:true,cancelable:false,contextInfo:{"resource-uri":"http://10.40.171.50:8080/exist/apps/RBS_path/adderPost.xq",
"response-headers":[null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */,null /* No converter found for 'net.sf.saxon.dom.NodeWrapper' */],
targetId:"post-instance",targetName:"submission",
"response-reason-phrase":"OK",
"response-status-code":200.0},currentTarget:null,eventPhase:1,
propertyNames:["resource-uri","response-headers","targetId","targetName","response-reason-phrase",
"response-status-code"],target:null,timeStamp:1437294248749,
type:"xforms-submit-done"}]);
    })();

Response Headers:
Content-Length:935
Content-Type:text/javascript; charset=utf-8
Date:Sun, 19 Jul 2015 08:24:08 GMT
Server:Jetty(8.1.9.v20130131)
EN

回答 1

Stack Overflow用户

发布于 2015-07-20 16:32:39

如果你想要替换一个实例,那么使用replace=“replace=”就可以替换整个页面。我还注意到你使用method="put",如果你想发帖,你应该使用method=" POST“。

有关工作示例,请参阅http://pastebin.ubuntu.com/11908113/ (xforms)和http://pastebin.ubuntu.com/11908115/ (xquery)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31499334

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档