You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ju...@hella.com on 2011/04/08 11:12:04 UTC

Problem with inputText conversion to BigDecimal

Hello everybody,

I have the following problem with conversion of an inputfield to a 
BigDecimal. The input has to distinguish between zero and empty string.

The page contains the following code: 

                <h:inputText value="#{sessionBean.testvar}">
                        <f:convertNumber type="number" />
                </h:inputText>

sessionBean.testvar ist a simple BigDecimal with default getter and 
Setter.

Submitting the page with a empty field sets testvar to an BigDecimal with 
value 0 and rerendering of the page brings up a "0" in the inputfield 
instead of leafing it empty.

Google and our analyse of the problem pointed the following:

We use this environment: Tomcat 6.0.32, MyFaces 1.2.10 

I found Tomcat runtime parameter 
-Dorg.apache.el.parser.COERCE_TO_ZERO="false" as a workaround.

https://issues.apache.org/bugzilla/show_bug.cgi?id=43285#c7
http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html

I don't want to use this workaround on our servers. (Not sure of 
side-effects on other apss)
What is the right solution to prevent this behaviour? Did I get sonething 
wrong?
Is there a better solution (in MyFaces I would prefer ;-) )?

Best regards

Jürgen Wieners


Re: Re: Problem with inputText conversion to BigDecimal

Posted by Mark Struberg <st...@yahoo.de>.
Hi Juergen!

Imo upgrading to JSF2 and EL-2.2. is always a good idea. I remember how nasty it was to handle actions in dataTables in JSF1. With EL-2.2 you now can just have your action as #{backingBean.delete(currentItem)} for example.
Or the <f:viewParam> or  <f:event type="PreRenderViewEvent" listener="#{backingBean.initMyBean}"/>

And these are just two of a long list of features which ease the life of a JSF developer in EE6!

LieGrue,
strub


--- On Fri, 4/8/11, Walter Mourão <wa...@gmail.com> wrote:

> From: Walter Mourão <wa...@gmail.com>
> Subject: Re: Re: Problem with inputText conversion to BigDecimal
> To: "MyFaces Discussion" <us...@myfaces.apache.org>
> Cc: Juergen.Wieners@hella.com
> Date: Friday, April 8, 2011, 12:01 PM
> As far as I know it is now the
> standard behavior...
> 
> Walter Mourão
> http://waltermourao.com.br
> http://arcadian.com.br
> http://oriens.com.br
> 
> 
> 
> On Fri, Apr 8, 2011 at 8:30 AM, <Ju...@hella.com>
> wrote:
> 
> > Hi.
> >
> > Thanks for the quick reply, it helps me fpr the
> moment.
> > So i'm thinking of what I will do.
> >
> > Little question : A upgrade to JSF 2 wouldn't solve
> this problem, or?
> >
> > Best regards
> >
> > Jürgen Wieners
> >
> > Abt.: HCC-GP-CP        - 
>       Tel.: 31007
> >
> >
> >
> > Von:    Walter Mourão <wa...@gmail.com>
> > An:     MyFaces Discussion <us...@myfaces.apache.org>
> > Kopie:  Juergen.Wieners@hella.com
> > Datum:  08.04.2011 12:42
> > Betreff:        Re: Problem with
> inputText conversion to BigDecimal
> >
> >
> >
> > Hi.
> >
> > Take a look at
> > http://myfaces.markmail.org/message/syt73xw5qkmlrcg2?q=COERCE_TO_ZERO
> >
> > I would suggest you create a String property to
> receive the value and make
> > the conversion in its setter (for example), or use
> Juel (
> > http://juel.sourceforge.net/ ). The problem in using a
> different
> > configuration to change the behavior is your app will
> not be 100%
> > compliant
> > with EL...
> >
> > Good luck,
> >
> > Walter Mourão
> > http://waltermourao.com.br
> > http://arcadian.com.br
> > http://oriens.com.br
> >
> >
> >
> > On Fri, Apr 8, 2011 at 6:12 AM, <Ju...@hella.com>
> wrote:
> >
> > > Hello everybody,
> > >
> > > I have the following problem with conversion of
> an inputfield to a
> > > BigDecimal. The input has to distinguish between
> zero and empty string.
> > >
> > > The page contains the following code:
> > >
> > >             
>   <h:inputText value="#{sessionBean.testvar}">
> > >             
>           <f:convertNumber
> type="number" />
> > >             
>   </h:inputText>
> > >
> > > sessionBean.testvar ist a simple BigDecimal with
> default getter and
> > > Setter.
> > >
> > > Submitting the page with a empty field sets
> testvar to an BigDecimal
> > with
> > > value 0 and rerendering of the page brings up a
> "0" in the inputfield
> > > instead of leafing it empty.
> > >
> > > Google and our analyse of the problem pointed the
> following:
> > >
> > > We use this environment: Tomcat 6.0.32, MyFaces
> 1.2.10
> > >
> > > I found Tomcat runtime parameter
> > > -Dorg.apache.el.parser.COERCE_TO_ZERO="false" as
> a workaround.
> > >
> > > https://issues.apache.org/bugzilla/show_bug.cgi?id=43285#c7
> > > http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html
> > >
> > > I don't want to use this workaround on our
> servers. (Not sure of
> > > side-effects on other apss)
> > > What is the right solution to prevent this
> behaviour? Did I get
> > sonething
> > > wrong?
> > > Is there a better solution (in MyFaces I would
> prefer ;-) )?
> > >
> > > Best regards
> > >
> > > Jürgen Wieners
> > >
> > >
> >
> >
> 

Re: Re: Problem with inputText conversion to BigDecimal

Posted by Walter Mourão <wa...@gmail.com>.
As far as I know it is now the standard behavior...

Walter Mourão
http://waltermourao.com.br
http://arcadian.com.br
http://oriens.com.br



On Fri, Apr 8, 2011 at 8:30 AM, <Ju...@hella.com> wrote:

> Hi.
>
> Thanks for the quick reply, it helps me fpr the moment.
> So i'm thinking of what I will do.
>
> Little question : A upgrade to JSF 2 wouldn't solve this problem, or?
>
> Best regards
>
> Jürgen Wieners
>
> Abt.: HCC-GP-CP        -        Tel.: 31007
>
>
>
> Von:    Walter Mourão <wa...@gmail.com>
> An:     MyFaces Discussion <us...@myfaces.apache.org>
> Kopie:  Juergen.Wieners@hella.com
> Datum:  08.04.2011 12:42
> Betreff:        Re: Problem with inputText conversion to BigDecimal
>
>
>
> Hi.
>
> Take a look at
> http://myfaces.markmail.org/message/syt73xw5qkmlrcg2?q=COERCE_TO_ZERO
>
> I would suggest you create a String property to receive the value and make
> the conversion in its setter (for example), or use Juel (
> http://juel.sourceforge.net/ ). The problem in using a different
> configuration to change the behavior is your app will not be 100%
> compliant
> with EL...
>
> Good luck,
>
> Walter Mourão
> http://waltermourao.com.br
> http://arcadian.com.br
> http://oriens.com.br
>
>
>
> On Fri, Apr 8, 2011 at 6:12 AM, <Ju...@hella.com> wrote:
>
> > Hello everybody,
> >
> > I have the following problem with conversion of an inputfield to a
> > BigDecimal. The input has to distinguish between zero and empty string.
> >
> > The page contains the following code:
> >
> >                <h:inputText value="#{sessionBean.testvar}">
> >                        <f:convertNumber type="number" />
> >                </h:inputText>
> >
> > sessionBean.testvar ist a simple BigDecimal with default getter and
> > Setter.
> >
> > Submitting the page with a empty field sets testvar to an BigDecimal
> with
> > value 0 and rerendering of the page brings up a "0" in the inputfield
> > instead of leafing it empty.
> >
> > Google and our analyse of the problem pointed the following:
> >
> > We use this environment: Tomcat 6.0.32, MyFaces 1.2.10
> >
> > I found Tomcat runtime parameter
> > -Dorg.apache.el.parser.COERCE_TO_ZERO="false" as a workaround.
> >
> > https://issues.apache.org/bugzilla/show_bug.cgi?id=43285#c7
> > http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html
> >
> > I don't want to use this workaround on our servers. (Not sure of
> > side-effects on other apss)
> > What is the right solution to prevent this behaviour? Did I get
> sonething
> > wrong?
> > Is there a better solution (in MyFaces I would prefer ;-) )?
> >
> > Best regards
> >
> > Jürgen Wieners
> >
> >
>
>

Antwort: Re: Problem with inputText conversion to BigDecimal

Posted by Ju...@hella.com.
Hi.

Thanks for the quick reply, it helps me fpr the moment.
So i'm thinking of what I will do.

Little question : A upgrade to JSF 2 wouldn't solve this problem, or?

Best regards

Jürgen Wieners

Abt.: HCC-GP-CP        -        Tel.: 31007



Von:    Walter Mourão <wa...@gmail.com>
An:     MyFaces Discussion <us...@myfaces.apache.org>
Kopie:  Juergen.Wieners@hella.com
Datum:  08.04.2011 12:42
Betreff:        Re: Problem with inputText conversion to BigDecimal



Hi.

Take a look at
http://myfaces.markmail.org/message/syt73xw5qkmlrcg2?q=COERCE_TO_ZERO

I would suggest you create a String property to receive the value and make
the conversion in its setter (for example), or use Juel (
http://juel.sourceforge.net/ ). The problem in using a different
configuration to change the behavior is your app will not be 100% 
compliant
with EL...

Good luck,

Walter Mourão
http://waltermourao.com.br
http://arcadian.com.br
http://oriens.com.br



On Fri, Apr 8, 2011 at 6:12 AM, <Ju...@hella.com> wrote:

> Hello everybody,
>
> I have the following problem with conversion of an inputfield to a
> BigDecimal. The input has to distinguish between zero and empty string.
>
> The page contains the following code:
>
>                <h:inputText value="#{sessionBean.testvar}">
>                        <f:convertNumber type="number" />
>                </h:inputText>
>
> sessionBean.testvar ist a simple BigDecimal with default getter and
> Setter.
>
> Submitting the page with a empty field sets testvar to an BigDecimal 
with
> value 0 and rerendering of the page brings up a "0" in the inputfield
> instead of leafing it empty.
>
> Google and our analyse of the problem pointed the following:
>
> We use this environment: Tomcat 6.0.32, MyFaces 1.2.10
>
> I found Tomcat runtime parameter
> -Dorg.apache.el.parser.COERCE_TO_ZERO="false" as a workaround.
>
> https://issues.apache.org/bugzilla/show_bug.cgi?id=43285#c7
> http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html
>
> I don't want to use this workaround on our servers. (Not sure of
> side-effects on other apss)
> What is the right solution to prevent this behaviour? Did I get 
sonething
> wrong?
> Is there a better solution (in MyFaces I would prefer ;-) )?
>
> Best regards
>
> Jürgen Wieners
>
>


Re: Problem with inputText conversion to BigDecimal

Posted by Walter Mourão <wa...@gmail.com>.
Hi.

Take a look at
http://myfaces.markmail.org/message/syt73xw5qkmlrcg2?q=COERCE_TO_ZERO

I would suggest you create a String property to receive the value and make
the conversion in its setter (for example), or use Juel (
http://juel.sourceforge.net/ ). The problem in using a different
configuration to change the behavior is your app will not be 100% compliant
with EL...

Good luck,

Walter Mourão
http://waltermourao.com.br
http://arcadian.com.br
http://oriens.com.br



On Fri, Apr 8, 2011 at 6:12 AM, <Ju...@hella.com> wrote:

> Hello everybody,
>
> I have the following problem with conversion of an inputfield to a
> BigDecimal. The input has to distinguish between zero and empty string.
>
> The page contains the following code:
>
>                <h:inputText value="#{sessionBean.testvar}">
>                        <f:convertNumber type="number" />
>                </h:inputText>
>
> sessionBean.testvar ist a simple BigDecimal with default getter and
> Setter.
>
> Submitting the page with a empty field sets testvar to an BigDecimal with
> value 0 and rerendering of the page brings up a "0" in the inputfield
> instead of leafing it empty.
>
> Google and our analyse of the problem pointed the following:
>
> We use this environment: Tomcat 6.0.32, MyFaces 1.2.10
>
> I found Tomcat runtime parameter
> -Dorg.apache.el.parser.COERCE_TO_ZERO="false" as a workaround.
>
> https://issues.apache.org/bugzilla/show_bug.cgi?id=43285#c7
> http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html
>
> I don't want to use this workaround on our servers. (Not sure of
> side-effects on other apss)
> What is the right solution to prevent this behaviour? Did I get sonething
> wrong?
> Is there a better solution (in MyFaces I would prefer ;-) )?
>
> Best regards
>
> Jürgen Wieners
>
>