English 中文(简体)
XForms: set default selection in dropdown in binding
原标题:

I have a main instance named myinstance which has the element color. Color can be Red , Blue , Green or Yellow . The colors are populated in a drop-down from another instance called colorsinstance . When my form loads, I want the default in the dropdown to be set to Green in the nodeset binding.

<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>

Main instance binding is as follows:

<xforms:bind nodeset="instance( myinstance )">
    <xforms:bind nodeset="./color" required="true()"/>
</xforms:bind>
最佳回答

The default value of the dropdown will reflect the value stored in the instance. You can either put the default directly in your instance, e.g.:

<color>Green</color>

Or you can set the value using setvalue, e.g. this in your model:

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

Updated following your comment: if you want to use the Orbeon Forms xxforms:default extension, then try:

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

Also updated to reflect the fact that instance data must contain "Green", not "Color3".

问题回答

暂无回答




相关问题
xform data grid

I am using orbeon to process my xforms. I am attempting to create a data grid that I can use to copy and paste rows/columns of data from my clipboard (excel). Do you have any clue how I can implement ...

Connect Chiba xForm to a restful web service (exist db)

I need to read an xml instance from an exist db. I am attempting to connect chiba to a restful web service via the following command: <xf:model> <xf:instance id="data-instance" ...

ISML PAC to XForm Conversion

Are there any tools or write-ups that can help in converting ISML PACs to XForms? Does anyone have experience in such a conversion?

XForms: how to deal with instance data that changes?

At the moment I am working on an XForms application to mutate XML data. This data comes from a local XML file. The file is exported from another application in a static way and read into the ...

Client side XForms processing tools [closed]

What would be the best client side javascript based XForms processor? I m trying to migrate plugin (activeX) based Xforms processing solution to a javascript based client side processor. But the ...

Default Values in XForms Input

I have an XForm that has certain fields that may often be left blank (optional street address). Is there is technique to set a default value for that field, preferably a space (I am running into weird ...

热门标签