Default values for an integer type field

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Default values for an integer type field

Robin Diederen
Default values for an integer type field Hello all,

I have this xform with quite a few xforms:input fields which are bound to xs:integer typed nodes. However, I'm allowed to enter whatever I want. When leaving the field (DomFocusOut) this always triggers an error. This error of course makes sense.

However... I don't want that behaviour. I want, in case of an invalid entry, a default value to be entered in the input box (0 for instance).

Can this be done? If so, how would I do this?

Best, Robin


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Default values for an integer type field

Karolin Heiss
Hey Robin

You can use events dispatched to an instance when it becomes valid or invalid:

<xforms:input ref="$test/number">
        <xforms:label>Enter number</xforms:label>
        <xforms:alert />
        <xforms:action ev:event="xforms-valid">
                                             
        </xforms:action>
        <xforms:action ev:event="xforms-invalid">
               
                <xforms:setvalue ref="$test">0</xforms:setvalue>
        </xforms:action>
</xforms:input>


Cheers Karolin


Reply | Threaded
Open this post in threaded view
|

Re: Default values for an integer type field

Binesh Gummadi
In reply to this post by Robin Diederen
Try changing your type from xs:integer to xforms:integer.
XML datatypes treats empty value as invalid value.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Default values for an integer type field

Erik Bruchez
Administrator
In reply to this post by Karolin Heiss
Similarly you can probably use a bind, like:

<xf;bind ref="number" calculate="if (. castable as xs:integer) then . else 0">

-Erik

On Tue, Aug 31, 2010 at 5:10 AM, Karolin Krieg <[hidden email]> wrote:

>
> Hey Robin
>
> You can use events dispatched to an instance when it becomes valid or
> invalid:
>
> <xforms:input ref="$test/number">
>        <xforms:label>Enter number</xforms:label>
>        <xforms:alert />
>        <xforms:action ev:event="xforms-valid">
>              <!--xforms:message level="modal">valid</xforms:message-->
>        </xforms:action>
>        <xforms:action ev:event="xforms-invalid">
>                <!--xforms:message level="modal">NOT valid</xforms:message-->
>                <xforms:setvalue ref="$test">0</xforms:setvalue>
>        </xforms:action>
> </xforms:input>
>
>
> Cheers Karolin
>
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Default-values-for-an-integer-type-field-tp2400435p2401427.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws