2010-06-10 119 views
1

我有一个名为'myinstance'的主实例,它具有元素的颜色。颜色可以是'红','蓝','绿'或'黄'。颜色从另一个名为'colorsinstance'的实例的下拉列表中填充。当我的表单加载时,我希望下拉列表中的默认值在节点集绑定中设置为“绿色”。XForms:在绑定的下拉列表中设置默认选择

<instance id="colorsinstance"> 
    <items> 
     <item label="Color1" value="Red"/> 
     <item label="Color2" value="Blue"/> 
     <item label="Color3" value="Green"/> 
     <item label="Color4" value="Yellow"/> 
    </items> 
</instance> 

主要实例绑定如下:

<xforms:bind nodeset="instance('myinstance')"> 
    <xforms:bind nodeset="./color" required="true()"/> 
</xforms:bind> 

回答

3

下拉的默认值将反映出存储在背景的值。您可以将默认值直接放入您的实例中,例如:

<color>Green</color> 

或者您可以使用setvalue设置值,例如,这在你的模型:

<xforms:setvalue ev:event="xforms-model-construct-done" 
       ref="color">Green</xforms:setvalue> 

更新您的评论如下:如果你想使用Orbeon形式xxforms:默认的扩展名,然后尝试:

<xforms:bind nodeset="./color" required="true()" xxforms:default="'Green'"/> 

而且更新以反映事实,实例数据必须包含“绿色”,而不是“Color3”。

+0

同意,我可以这样做。但我有具体的说明,只能在使用xxforms:default的节点集绑定中设置默认值。我需要通过从colorsinstance获取值'Green'来设置instance('myinstance')/ color = Green的值。 – Purni 2010-06-11 15:32:09

+0

谢谢!这样可行。 – Purni 2010-06-16 22:24:58

+0

@ebruchez,我是一个新的orbeon用户。你能帮我的查询,http://stackoverflow.com/questions/29213996/where-can-we-get-the-form-data-in-xml-metadata-format-on-click-of-send -button-EV。我尝试了很多与多个构建与调试声明数量,但莫使用和浪费3天找到这个简单的解决方案,任何建议请 – Vinod 2015-03-24 14:39:49

相关问题