首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Orbeon中加载和传递Xforms表单(如何将实例发送到XForms)?

如何在Orbeon中加载和传递Xforms表单(如何将实例发送到XForms)?
EN

Stack Overflow用户
提问于 2010-05-31 14:43:13
回答 2查看 2.2K关注 0票数 1

我正在使用Orbeon窗体解决方案从填入的web表单中生成消息。

我在Orbeon的wiki中从管道中读取了不同的代码片段,我尝试了不同的解决方案,但它不起作用,没有一个例子是管道中的POST,它被PFC捕获并发送到接收已发布数据的XForms视图(所有示例都是在同一个页面中完成的)。

我在他的实例输入中收到了以下管道:

pipelineWrite.xpl

代码语言:javascript
复制
<p:config ...>
    <p:param name="instance" type="input"/> <!-- instance containing the data of the form filled by user -->
    <p:param name="data" type="output"/>

    <p:processor name="oxf:java"> <!-- transforms the data into a file -->
        <p:input name="config">
            <config sourcepath="." class="ProcessorWriteCUSDECCD001B"/>
        </p:input>
        <p:input name="input" href="#instance"/>
        <p:output name="output" id="file"/> <!-- XML containing the url of the file -->
    </p:processor>       
</p:config> 

然后是PFC,它捕捉这些行为:

页面-flow.xml.xml

代码语言:javascript
复制
<config xmlns="http://www.orbeon.com/oxf/controller">

    <page path-info="/CUSDECCD001B/" view="View/ViewForm.xhtml"/> <!-- load the form to be filled in by user -->

    <page path-info="/CUSDECCD001B/write" model="Controller/PipelineWrite.xpl"/> <!-- send the instance of the form filled to the pipeline above -->

    <page path-info="/CUSDECCD001B/success" view="View/ViewSuccess.xhtml"/> <!-- send the instance containing the url of the file to the success view -->

    <epilogue url="oxf:/config/epilogue.xpl"/>
</config> 

然后是成功视图,非常简单:

ViewSuccess.xhtml

代码语言:javascript
复制
<html ... >
  <head>
    <title>Generation OK</title>
    <xforms:model>
            <xforms:instance id="FILE" src="input:instance">
                <files xmlns="">
                    <file mediaType="" filename="" size="" />
                </files>
            </xforms:instance>
        </xforms:model>
  </head>
  <body>
        Click here to download :
        <xforms:output ref="//file" appearance="xxforms:download">
            <xforms:filename ref="@filename"/>
            <xforms:mediatype ref="@mediatype"/>
            <xforms:label>Download</xforms:label>
        </xforms:output>
  </body>
</html> 

我通过单击"ViewModify“页面中的"Save”按钮启动了所有这些过程:

ViewModify.xhtml

代码语言:javascript
复制
<xforms:model>
    <xforms:instance id="CUSDECCD001B" src="../apps/CUSDECCD001B/Model/ModelCUSDECCD001B.xml" />
    <xforms:submission id="save-submission" ref="instance('CUSDECCD001B')" action="/CUSDECCD001B/write" replace="instance" instance="CUSDECCD001BFile">
        <xforms:send ev:event="xforms-submit-done" submission="send-to-success"/>
    </xforms:submission>
    <xforms:submission id="send-to-success" method="post" action="/CUSDECCD001B/success" ref="instance('CUSDECCD001BFile')" replace="all"/>
</xforms:model>

  <!-- .... Content of XForms form -->

<xforms:submit submission="save-submission">
    <xforms:label>Save</xforms:label>
</xforms:submit>

问题是post做得很好,PFC很好地捕捉了操作,加载了正确的视图,但是视图中没有数据(视图没有在他的实例输入中找到数据)。

我试图在视图中使用GET检索POST数据,这是一样的。不检索任何数据。所以下载按钮不起作用。

我希望我能清楚地找到解决办法。提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-06-06 20:52:53

在考虑到Alessandro并在Orbeon wiki上搜索其他代码片段之后,下面的解决方案对我来说很好:

在其实例输入上接收已填充的表单实例的管道:

piplineWrite.xpl

代码语言:javascript
复制
<p:param name="instance" type="input"/>
<p:param name="data" type="output"/>

<p:processor name="oxf:java">
    <p:input name="config">
        <config sourcepath="." class="ProcessorWrite"/>
    </p:input>
    <p:input name="input" href="#instance"/>
    <p:output name="output" ref="data"/>
</p:processor>

PFC的捕捉动作和相应的动作:

页面-flow.xml.xml

代码语言:javascript
复制
<config xmlns="http://www.orbeon.com/oxf/controller">
    <page path-info="/CUSDECCD001B/write" view="Controller/PipelineWrite.xpl"/>
    <page path-info="/CUSDECCD001B/success" view="View/ViewSuccess.xhtml"/>
    <epilogue url="oxf:/config/epilogue.xpl"/>
</config>

视图在处理后成功接收数据输出:

viewSuccess.xhtml

代码语言:javascript
复制
<html ...>
  <head>
    <xforms:model>
        <xforms:instance id="FILE" src="input:instance"/>
    </xforms:model>
  </head>
  <body>

    <p> Generation Success !</p>

    <div class="toolbar">
        Cliquer to download :
        <xforms:output ref="//file" appearance="xxforms:download">
            <xforms:filename ref="@filename"/>
            <xforms:mediatype ref="@mediatype"/>
            <xforms:label>Download</xforms:label>
        </xforms:output>
    </div>
  </body>
</html>

视图使用"Save“按钮修改整个过程:

viewModify.xhtml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <xforms:model>
      <xforms:instance id="CUSDECCD001BFile">
        <dummy xmlns="" />
      </xforms:instance>
      <xforms:submission id="save-submission" ref="instance('CUSDECCD001B')" action="/CUSDECCD001B/write" method="post" replace="instance" instance="CUSDECCD001BFile">
        <xforms:action ev:event="xforms-submit">
          <xforms:send submission="send-submission" />
        </xforms:action>
      </xforms:submission>
      <xforms:submission id="send-submission" ref="instance('CUSDECCD001BFile')" action="/CUSDECCD001B/success" method="post" />
    </xforms:model>
  </head>
  <body>
    ...
    <xforms:submit submission="save-submission">
      <xforms:label>Save</xforms:label>
    </xforms:submit>
  </body>
</html>

前面给出的代码片段和建议中的主要问题是:

  • <xforms:instance>必须指定resource=""或至少包含默认内容(此处为<dummy />),
  • xforms-submit-done事件似乎不起作用,也不存在。所以,我使用了一个xforms-submit事件。
票数 0
EN

Stack Overflow用户

发布于 2010-06-01 22:49:59

只有xforms:submission replace="instance"在从oxf:xforms-submission处理器中使用时才有意义。因此,提交的结果必须返回XML,但这在这里行不通,因为当您向XForms页面提交时,就会返回HTML。

我假设您有一个表单可以将replace="all"提交给/CUSDECCD001B/write。相反:

  1. 执行提交replace="instance"并将结果存储在实例中。
  2. pipelineWrite.xpl中,直接返回file处理器的file输出,而不调用XForms提交处理器。
  3. 回到执行replace="instance"/CUSDECCD001B/write的提交的/CUSDECCD001B/write中,当提交完成(xforms-submit-done)时,运行另一个将结果发布到/CUSDECCD001B/success的提交。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2944233

复制
相关文章

相似问题

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