开发者

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:def开发者_运维知识库ault, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜