English 中文(简体)
xforms: how to prevent xxforms:default value from over-writing user input
原标题:

I have a dropdown to display status, which can be Enabled(true) or Disabled(false). Here is my xml instance.

<?xml version="1.0" encoding="UTF-8"?>
    <page>
        <file-name></file-name>
        <status></status>
    </page>

By default, status should be true. So I have set it in binding as follows.

<xforms:bind nodeset="./status" xxforms:default="true()" />

When user chooses Disabled in the dropdown, the status should get saved as false. Here is the xml that gets saved when I save the form.

<page>
    <file-name>StatusDisabled.xml</file-name>
    <status>false</false>
</page>

When I open the form in edit mode, this is the xml I get in the XML inspector widget.

<page>
    <file-name>StatusDisabled.xml</file-name>
    <status>true></status>
</page>

Status gets set to true because of xxforms:default, even though the xml is saved with a false value for status.

How can I fix this?

Here is the xhtml:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">

    <head>
        <title>XForms Default</title>

        <xforms:model>
            <xforms:instance id="instance">
                <page>
                    <name xmlns=""/>    
                    <status xmlns=""/>
                </page>
            </xforms:instance>

            <xforms:instance id="status-instance">
                <items>
                    <item label="Enabled" value="true" xmlns=""/>
                    <item label="Disabled" value="false" xmlns=""/>
                </items>
            </xforms:instance>

            <xforms:bind nodeset="instance( instance )">
                <xforms:bind nodeset="./status" xxforms:default="true()" />
            </xforms:bind>

        </xforms:model>
    </head>
    <body>
        <p>
            <xforms:input ref="instance( instance )/name" incremental="true">
                <xforms:label>Please enter your name:</xforms:label>
            </xforms:input>
        </p>
        <p>
            <xforms:select1 ref="instance( instance )/status" appearance="minimal" incremental="true">
                <xforms:label>Please select status:</xforms:label>
                <xforms:itemset nodeset="instance( status-instance )/item">
                    <xforms:label ref="./@label"/>
                    <xforms:value ref="./@value"/>
                </xforms:itemset>
            </xforms:select1> 
        </p>
    </body>
</html>
最佳回答

If this happens, it s a bug. xxforms:default should only be evaluated once.

问题回答

暂无回答




相关问题
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 ...

热门标签