2015-04-01 31 views
0

我可以在Orbeon中使用只讀xf:輸入行爲,如xf:輸出嗎? 如何設置只讀輸入字段的值?在Orbeon中使用只讀xf:輸入作爲xf:輸出?

簡單的代碼示例:

<xf:input ref="//Some/Elements/TotalCredit" 
      value="round(($quantity) * ($creditPerUnit))"> 
</xf:input > 

<xf:output ref="//Some/Elements/TotalCredit" 
      value="round(($quantity) * ($creditPerUnit))"/> 

在上面的代碼中XF:輸入僅示出了從模型的初始值! 它不更新! 但是xf:輸出值按預期更新! enter image description here

那麼,怎樣才能設置XF:輸入的價值就像XF:輸出

  • 我不想在綁定中使用計算。

回答

1

在你的例子中,你有一個xf:inputrefvalue;我不知道你想到這個做什麼,或者如果是有道理的,但可以肯定它目前是行不通的:

  • 隨着xf:output,你可以同時擁有一個refvalue,其中由ref指向的節點可以影響是否顯示xf:output並且value是否給出了它的值。

  • 如果您想對xf:input執行相同的操作,它可以將計算結果置於ref(在您的案例中爲round(($quantity) * ($creditPerUnit)))。如果該表達式返回一個原子值,那麼輸入字段將是隻讀的,我認爲這應該照顧您的情況。

+0

我知道輸入綁定中的一種計算方式,但在我的情況下,我不能使用這種方式,因爲xf:input在xf:repeat內,而不在它的nodeset!它指的是在重複節點之外的節點。我可以通過View來綁定變量來計算嗎? – oikonomopo 2015-04-02 06:22:40

+0

是的,您應該可以在計算中使用重複範圍外的字段值。如果這是使用Form Builder創建的表單,則可以在計算中將該值引用爲「$ control-name」,其中'control-name'是重複之外的該字段的控件名稱。 – avernet 2015-04-07 06:48:55

0

這是我做到了,考慮thisthis職位。 「啓用的XForms xxforms迭代,移動的XForms的值改爲」 事件=

//First Input 
    <xf:input ref="//Some/Elements/PreviousInputCreditPerUnit"> 
     <xf:action ev:event="xforms-enabled xxforms-iteration-moved xforms-value-changed"> 
     <xf:setvalue 
      ref="//Some/Elements/ReadOnlyInputIK" 
      value="round(($quantity) * ($creditPerUnit))"/> 
     </xf:action> 
    </xf:input> 

    //Second input 
    <xf:input ref="//Some/Elements/PreviousInputQuantity"> 
     <xf:action ev:event="xforms-value-changed"> 
     <xf:setvalue 
      ref="//Some/Elements/ReadOnlyInputIK" 
      value="round(($quantity) * ($creditPerUnit))"/> 
     </xf:action> 
    </xf:input> 

    //Third ReadOnly Input (acts like xf:output) 
    <xf:input ref="//Some/Elements/ReadOnlyInput"> 
    </xf:input> 

注意,在我的再三行的第一列中的操作事件:

EV

See this example from Orbeon.