myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Heinen" <...@recommind.com>
Subject number conversion and null values
Date Tue, 11 Sep 2007 13:00:17 GMT
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