2015-08-13 27 views
1

我有興趣在提交表單並將其鏈接到用戶(即通過表單的必填字段中的電子郵件)時獲取documentId。這個想法也是調用web服務併發送這兩個字段來建立這種關係。現在,我想在一個領域看到這個價值。Orbeon獲取documentId

首先,我發現我可以使用xxforms:instance('fr-parameters-instance')/document來實現這一點,但我沒有成功。

在此之後,我看到現在(我用Orbeon 4.9)更改爲fr:document-id()但目前看來,我仍然無法看到該文件ID形式的簡單場here。 Bassically,是這樣的:使用表單生成器創建

<xf:action ev:event="xforms-submit"> 
    <xf:setvalue ref="instance('fr-form-instance')/somefield" value="fr:document-id()"/> 
</xf:action> 

簡單的例子:

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:ev="http://www.w3.org/2001/xml-events" 
    xmlns:xi="http://www.w3.org/2001/XInclude" 
    xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" 
    xmlns:xxf="http://orbeon.org/oxf/xml/xforms" 
    xmlns:exf="http://www.exforms.org/exf/1-0" 
    xmlns:fr="http://orbeon.org/oxf/xml/form-runner" 
    xmlns:saxon="http://saxon.sf.net/" 
    xmlns:sql="http://orbeon.org/oxf/xml/sql" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:fb="http://orbeon.org/oxf/xml/form-builder"> 
<xh:head> 
    <xh:title>Send OrbeonID</xh:title> 
    <xf:model id="fr-form-model" xxf:expose-xpath-types="true"> 

     <!-- Main instance --> 
     <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all"> 
      <form> 
       <section-1> 
        <control-1/> 
       </section-1> 
      </form> 
     </xf:instance> 

     <!-- Bindings --> 
     <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')"> 
      <xf:bind id="section-1-bind" name="section-1" ref="section-1"> 
       <xf:bind id="control-1-bind" name="control-1" ref="control-1"/> 
      </xf:bind> 
     </xf:bind> 

     <!-- Metadata --> 
     <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all"> 
      <metadata> 
       <application-name>Biit</application-name> 
       <form-name>SendOrbeonID</form-name> 
       <title xml:lang="en">Send OrbeonID</title> 
       <description xml:lang="en"/> 
       <singleton>false</singleton> 
      </metadata> 
     </xf:instance> 

     <!-- Attachments --> 
     <xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all"> 
      <attachments> 
       <css mediatype="text/css" filename="" size=""/> 
       <pdf mediatype="application/pdf" filename="" size=""/> 
      </attachments> 
     </xf:instance> 

     <!-- All form resources --> 
     <!-- Don't make readonly by default in case a service modifies the resources --> 
     <xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all"> 
      <resources> 
       <resource xml:lang="en"> 
        <section-1> 
         <label>Untitled Section</label> 
        </section-1> 
        <control-1> 
         <label>Write something:</label> 
         <hint/> 
         <alert/> 
        </control-1> 
       </resource> 
      </resources> 
     </xf:instance> 

     <!-- Utility instances for services --> 
     <xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all"> 
      <request/> 
     </xf:instance> 

     <xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all"> 
      <response/> 
     </xf:instance> 

     <!-- Form is sent -->   
     <xf:action ev:event="xforms-submit"> 
      <xf:setvalue ref="instance('fr-form-instance')/section-1/control-1" value="fr:document-id()"/> 
     </xf:action>     

    </xf:model> 
</xh:head> 
<xh:body> 
    <fr:view> 
     <fr:body xmlns:xbl="http://www.w3.org/ns/xbl" 
       xmlns:oxf="http://www.orbeon.com/oxf/processors" 
       xmlns:p="http://www.orbeon.com/oxf/pipeline"> 
      <fr:section id="section-1-control" bind="section-1-bind"> 
       <xf:label ref="$form-resources/section-1/label"/> 
       <fr:grid> 
        <xh:tr> 
         <xh:td> 
          <xf:input id="control-1-control" bind="control-1-bind"> 
           <xf:label ref="$form-resources/control-1/label"/> 
           <xf:hint ref="$form-resources/control-1/hint"/> 
           <xf:alert ref="$fr-resources/detail/labels/alert"/> 
          </xf:input> 
         </xh:td> 
         <xh:td/> 
        </xh:tr> 
       </fr:grid> 
      </fr:section> 
     </fr:body> 
    </fr:view> 
</xh:body> 
</xh:html> 

Theorically,如果我fill up輸入字段,並按下提交或保存按鈕,該字段必須與文檔更新ID。但我無法看到任何價值。

回答

0

最後,我發現發送文檔Id的方式正在改變Orbeon中按鈕的行爲。

在保存爲草稿按鈕:

<property as="xs:string" name="oxf.fr.detail.process.save-draft.*.*"> 
    save 
    then send("oxf.fr.detail.save-draft.success") 
    then success-message("save-draft-success") 
    recover error-message("database-error") 
</property> 

,並定義send行動的地方之外Orbeon:

<property as="xs:boolean" name="oxf.fr.detail.new.accept-post.*.*" value="true" /> 
<property as="xs:string" name="oxf.fr.detail.save-draft.success.uri.*.*" value="http://localhost:8080/get-id.jsp?document={xxf:instance('fr-parameters-instance')/document}"/> 
<property as="xs:string" name="oxf.fr.detail.save-draft.success.method.*.*" value="post"/> 

JSP頁面get-id.jsp現在每次執行用戶保存草稿的形式,但瀏覽器不會重定向到JSP頁面。

更改爲使用web服務或其他操作必須簡單。

+0

是的,證實了一個web服務也有效。 – JorgeHortelano

0

好消息是默認情況下文檔ID已經作爲URL參數發送。 URL參數名稱是document。另見相關的documentation

+0

好的,謝謝你的答案。它接近我所需要的。我要測試它,看看我是否可以通過這種方式檢索文檔ID並繼續執行我的過程。 – JorgeHortelano

+0

似乎幾乎是一個解決方案。我可以更改發送操作並將document_id和電子郵件發送到URL。但是我的休息服務受到保護,這就是我嘗試使用Orbeon的標準Web服務功能的原因。現在,我可以將這些信息發送到處理授權和重新發送數據的JSP頁面,但也許存在一個更好的方法來做到這一點,而不需要中間的jsp頁面。 – JorgeHortelano

+0

不,使用JSP頁面只是「發送」按鈕的解決方案,但如果我使用「保存」按鈕,則無法繼續處理表單。我不確定您編寫的關於「更強大的按鈕」的文檔是否允許我這樣做,或者繼續推出啓動web服務的最初想法。 – JorgeHortelano

0

當您設置的計算值的表單生成控件

xxf:instance('fr-parameters-instance')/document 

你可以得到的文檔ID。

+0

是的,這正是我所接受的答案中所描述的。 – JorgeHortelano