2011-11-29 227 views
2

如何設置所選值在XForms中選擇1不使用實例?默認選擇的值:選擇1

例如,我有這樣的實例:

<lEmpleado_Id></lEmpleado_Id> 
<sEmpleado_Nm xsi:type="xs:string"></sEmpleado_Nm> 
<iCargo_Id xsi:type="xs:int"></iCargo_Id> 
<iProfesion_Id xsi:type="xs:int"></iProfesion_Id> 

<iHorario_Id xsi:type="xs:int"></iHorario_Id> 
<iConcurrencia_Id>1</iConcurrencia_Id> 

,我想使這個選擇1取默認值:

<xf:select1 ref="iHorario_Id"> 
    <xf:label>Horario</xf:label> 
    <!--This is the default item I Want to be selected--> 
    <xf:item> 
     <xf:label>Select a schedule...</xf:label> 
     <xf:value>0</xf:value> 
    </xf:item> 
    <!--End Here--> 
    <xf:item> 
     <xf:label>Schedule 1</xf:label> 
     <xf:value>1</xf:value> 
    </xf:item> 
</xf:select1> 

但是當我驗證了XForms我想,如果這在選擇項目時,XForm中不提交的,但如果選擇了其他的項目,通常提交,香港專業教育學院tryed與<xf:bind,但我不知道如何把一個MINVALUE或類似的東西,該元素

回答

2

xforms:bind是正確的方向;你只需要把一個constraintiHorario_Id元素:

<xf:bind nodeset="iHorario_Id" constraint=". gt 0" /> 

這使得iHorario_Id有效只有當它的值大於0,所以,你可以的iHorario_Id初始值設置爲0,以防止任何提交,直到時間表被選中。

+0

的感謝!它的作用就像一個魅力,但我不得不使用「>」符號代替「gt」,因爲它給了我一個解析器錯誤 – jmacboy

+2

'gt'是一個XPath 2操作符,所以如果你的實現使用XPath 1,你必須使用'>相反。 – ebruchez