I'm new to JSF, so this question might be weird. I have the value of an input code that is bound to the property of the managed float type float. When the inputText field is empty, 0 does not have the values, I need to empty the property. This is not done by default, so I have implemented the converter with the following method:
public object getAsObject (FacesContext arg0, UIComponent arg1, string arg2) converter exception {if (StringUtils .isEmpty (arg2)) {return tap; } Float result = float. Pircephlot (arg2); If (result == 0) {return tap; } Return results; }
I have registered the converter, and have handed it to the input text component. I have logged arg2 logic, and have entered the value returned by the getAsObject method. From my logs I can see that it gives zero value. However, I also log the Setter property on the backing bean and the argument is 0 value, the expected tap is not to be more precise, it says twice the setter property, once with zero argument, 0 with the value argument the second time goes.
It still sets the value of 0 to bean. How can I set the value to blank? / P>
In advance thanks
When null
in ReturnAsObject ()
is returning, you must also set the value of the component as the null
.
if (result == empty) {(EditableValueHolder component) .setSubmittedValue (null); }
However, there is an environment specific issue with it, that is, the fact is that in the Tomcat 6.0.16 or the new EL Parser, still in favor of viewing this value as 0 , Even if getAsString ()
returns null
. You can go around this by adding the following line for Tomcat's VM arguments:
-Dorg.apache.el.parser.COERCE_TO_ZERO = false
Comments
Post a Comment