This content has been marked as final. 
    
Show                 4 replies
    
- 
        1. Re: Question on Converterfhh Apr 1, 2007 10:59 AM (in response to hasc)Why is #{MyEntityConverter} an EL expression? This will (most likely) come out as null. So you are not setting a converter at all. 
 Regards
 Felix
- 
        2. Re: Question on Converterhasc Apr 1, 2007 11:29 AM (in response to hasc)right. this was from a try to bind the converter via a getter method like in the dvd example. 
 i also tried it with:<h:inputText id="EffectiveArea" value="#{calculator.area}"> <f:converter converterId="AreaConverter"/> </h:inputText>
 or...<h:inputText id="EffectiveArea" value="#{calculator.area}" converter="AreaConverter"/>
 in faces-config there's:<converter> <converter-id>AreaConverter</converter-id> <converter-class>my.webapp.converter.AreaConverter</converter-class> </converter> 
- 
        3. Re: Question on Converterhasc Apr 1, 2007 12:14 PM (in response to hasc)sorry i was wrong. it seems to use the converter. 
 i have a question regarding the converter.#{calculator.area}
 the expression references a property which is defined here:@Stateful class CalculatorBean implements Calculator float area; public void setArea(float area) { this.area = area; } public float getArea() { return area; } public void calculate(){do something}
 now what i want is, that if the property area is not set, the form field should be empty.
 if no converter is specified #{calculator.area} is rendered to "0.0".
 I tried the following in the toString method of the AreaConverter class:public String getAsString(FacesContext facesContext, UIComponent component, Object obj) { if(obj == null || obj.equals(0.0)) { String str = ""; return str; } return obj.toString(); }
 but it still returns "0.0"
 has somone a hint why this happens?
- 
        4. Re: Question on Converterhasc Apr 1, 2007 12:23 PM (in response to hasc)public String getAsString(FacesContext facesContext, UIComponent component, Object obj) { Float val = (Float) obj; if(val == null || val == 0) { String str = ""; return str; } return obj.toString(); }
 solved this question...
 
    