I want to let users edit a field with double data in Grails view. I want to allow Double.NaN (to void values).
There is a special char looking like a diamond with a question mark in it (in HTML) that acts like NaN, but - well - the users wont find that on their keys.
In Java it works with Double.valueOf("NaN")
. But typing NaN in the input field will throw a IllegalArgumentException saying "NaN" is an Unparseable Number.
What method is callled for conversion? Whats the key to let it autoconvert to a double?
If you use
Double
instead ofdouble
in the domain class or command object, and usenullable:true
in the constraints ´null´ acts as 'no data' value.If you really want to stick to NaN, you have to register a custom propertyeditor, see http://ishanf.tumblr.com/post/434379583/custom-property-editor-for-grails.