I have a <h:inputText>
which accepts a long
value like this
<h:inputText value="#{ServiceTable.ID}" />
The property is declared like this
public class ServiceTable {
private long ID;
// Getter and setter for ID.
}
When I open the page, I always see 0
in the textbox. How can I avoid it? I just need an empty textbox. I am using JSF 1.2.
Use Long
instead of long
. It defaults to null
.
private Long ID;
And, if you're running Tomcat 6.0.16 or newer or a fork of it, then you need to add the following VM argument to server startup arguments as well to disable EL coercion of primitives and their wrappers:
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
awful! many developers do not have access to the actual server, and sometimes you just cant go to the client and tell him :" stop your server and restart everything with this start up options".
How come people in the apache team never thought about that?
If you are in such situation - like myself - another solution is to get the field as a String and parse it manually in your backing bean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With