How to bind a check box to number value

Sometimes you find in your data model columns of type smallint which are used as bit. We have this very often with our old code because this code was originally written at a time when there was no bit datatype in database available. Also you still finde database vendors who do not offer this bit datatype. So when you want to use a check box in your UI and you want to assign it to 0 and 1 in your database column then you could do this as follows. In this example we have a table named "aagfakt" and a column named "storno" of type smallint.

Code Example:

${aagfakt.storno == 1}

And then in change-event of check box:

Code Example:

${aagfakt.storno = (short)(args ? 1 : 0)}