myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <mkien...@gmail.com>
Subject Re: number conversion and null values
Date Tue, 11 Sep 2007 20:52:19 GMT
Maybe <f:convertNumber pattern="###.##"/> instead?  I'm not an expert
on format patterns, but doesn't 0 mean "at least one digit?"



On 9/11/07, Michael Heinen <mhn@recommind.com> wrote:
>
>
>
>
> I have a conversion problem with doubles and null values.
>
>
>
> JSP snippet:
>
> <h:inputText
>
> value="#{!empty MyController.category&& MyController.category.treshold>=0?
> MyController.category.treshold:''}">
>
>   <f:convertNumber pattern="##0.##"/>
>
> </h:inputText>
>
>
>
> Class Category
>
>   public double getTreshold()
>
>   {
>
>     return this.mTreshold;
>
>   }
>
>   public void setTreshold(double treshold)
>
>   {
>
>     this.mTreshold = treshold;
>
>   }
>
>
>
> This is working fine if I enter valid doubles.
>
> The following message is displayed if I enter nothing in the input field:
>
>
>
> Exception setting property Threshold: of base with class
> com.recommind.litigation.client.web.model.Category, Bean:
> com.recommind.litigation.client.web.model.Category,
> property: Threshold:, newValue: null ,newValue class: null method parameter
> class: double, null
>
>
>
> The getAsObject method of the NumberConverter returns null as expected.
>
>
>
> What should I do now with the treshold property of the Category class ?
>
> I tried without success:
>
> - setTreshold(Double treshold)
>
> - setTreshold(Number treshold)
>
>
>
> A workaround is to set the value to 0 via javascript but this is not a good
> alternative.
>
>
>
> Michael

Mime
View raw message