Grails 2.0.0.RC1, BigDecimals and Scaffolding

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 2.0.0.RC1, BigDecimals and Scaffolding

Konstantinos Kostarellis
I experienced all sort of strange behaviors in scaffolded input fields for BigDecimals.
The scaffolded view would only show 3 floating point numbers, even if the scale-constraint is set higher e.g.: (scale:5).
So you might be able to input the correct amount or even more in some browsers (e.g. Firefox) but then it will show you
only 3 of the after comma decimals and on the next edit/update you will loose the information.

As you might have noticed I mentioned in some browsers. There is a Browser problem too.
As scaffolding generates an html 5 input field
<input type="number" .... 
in some Browsers (e.g. Chrome/Opera) it is impossible to input a BigDecimal, esp. if you change your locale to something like German (?lang=de).
They only accept integers.

Can someone confirm that behaviors, so I can raise a jira ? 
On a first quick search in the jira-db I couldn't find the described problems.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

Konstantinos Kostarellis
Nobody here that has tryed to scaffold domains with BigDecimals in Grails 2.x ?

2011/10/27 Konstantinos Kostarellis <[hidden email]>
I experienced all sort of strange behaviors in scaffolded input fields for BigDecimals.
The scaffolded view would only show 3 floating point numbers, even if the scale-constraint is set higher e.g.: (scale:5).
So you might be able to input the correct amount or even more in some browsers (e.g. Firefox) but then it will show you
only 3 of the after comma decimals and on the next edit/update you will loose the information.

As you might have noticed I mentioned in some browsers. There is a Browser problem too.
As scaffolding generates an html 5 input field
<input type="number" .... 
in some Browsers (e.g. Chrome/Opera) it is impossible to input a BigDecimal, esp. if you change your locale to something like German (?lang=de).
They only accept integers.

Can someone confirm that behaviors, so I can raise a jira ? 
On a first quick search in the jira-db I couldn't find the described problems.

Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

Nick Vaidyanathan
Problem confirmed.
Scale not respected.
The Number input type doesn't allow decimal points by default, even in US locale, in Chrome. (oops)

On Fri, Oct 28, 2011 at 12:59 PM, Konstantinos Kostarellis <[hidden email]> wrote:
Nobody here that has tryed to scaffold domains with BigDecimals in Grails 2.x ?


2011/10/27 Konstantinos Kostarellis <[hidden email]>
I experienced all sort of strange behaviors in scaffolded input fields for BigDecimals.
The scaffolded view would only show 3 floating point numbers, even if the scale-constraint is set higher e.g.: (scale:5).
So you might be able to input the correct amount or even more in some browsers (e.g. Firefox) but then it will show you
only 3 of the after comma decimals and on the next edit/update you will loose the information.

As you might have noticed I mentioned in some browsers. There is a Browser problem too.
As scaffolding generates an html 5 input field
<input type="number" .... 
in some Browsers (e.g. Chrome/Opera) it is impossible to input a BigDecimal, esp. if you change your locale to something like German (?lang=de).
They only accept integers.

Can someone confirm that behaviors, so I can raise a jira ? 
On a first quick search in the jira-db I couldn't find the described problems.


Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

kurb70
In reply to this post by Konstantinos Kostarellis
Unfortunately I have to confirm this behavior.

<quote author="Konstantinos Kostarellis">
As scaffolding generates an html 5 input field
<input type="number" ....
 in some Browsers (e.g. Chrome/Opera) it is impossible to input a
BigDecimal, esp. if you change your locale to something like German
(?lang=de).
They only accept integers.
</quote>
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

Konstantinos Kostarellis
I raised a jira on this issue

Better late then never :)

Cheers,
   Kosta

2011/10/29 kurb70 <[hidden email]>
Unfortunately I have to confirm this behavior.


As scaffolding generates an html 5 input field
<input type=&quot;number&quot; ....
 in some Browsers (e.g. Chrome/Opera) it is impossible to input a
BigDecimal, esp. if you change your locale to something like German
(?lang=de).
They only accept integers.
&lt;/quote>


--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-2-0-0-RC1-BigDecimals-and-Scaffolding-tp3943888p3950839.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

jlpp
Has anyone found a workaround for this issue?

I've got the following domain class property:
  BigDecimal pH

With this constraint:
  pH(min: 0.00, max: 14.00, scale: 2)

When trying to enter a decimal value in the generated edit page and Chrome, I get an Invalid Number error. Does anyone have any suggestions on how to address this?

Thanks,
Jeff
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

jlpp
This is the generated HTML, for reference:

<input type="number" name="pH" min="0.00" max="14.00" required="" value="6" id="pH" />
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

jlpp
Workaround for me is to edit _form.gsp and change the generated pH form field to add step="any". See http://code.google.com/p/chromium/issues/detail?id=44116 
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.0.0.RC1, BigDecimals and Scaffolding

to


Hope it helps.
sukarsa
In reply to this post by jlpp
This is a workaround solution that works for me:
Modify the scaffolding generator files in <project-dir>/src/templates/scaffolding (I think only "show.gsp" and "renderEditor.template" files)  
Replace all the \${fieldValue(...)} to \${<class-name>.<field-name>}.
 
For example:
\${fieldValue(bean: ${propertyName}, field: "${p.name}")}\${${propertyName}.${p.name}}