2011-11-29 221 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