This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSF and the fly likes mapping double value to inputText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "mapping double value to inputText" Watch "mapping double value to inputText" New topic

mapping double value to inputText

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Hi all,

I have a inputText which i mapped to a double value in the ManagedBean, when the page gets loaded the textfield displays 0.0 since it has been mapped as double value. Is it possible to display blank in the textfield if the value is 0.0, if i map it to a String and later parse the value to double in the backing bean it will work. Just wondering if JSF has anything inbuilt to handle this scenario.

[ March 24, 2006: Message edited by: Rajeev Ravindran ]

SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Ish Rawal

Joined: Feb 07, 2006
Posts: 2
Hi Rajeev,
JSF has nothing to do with it. You will have to write some logic for it. You can just pass a parameter names "success=true" to the jsp after submitting the form. And in your jsp just do like this

<% if(request.getParameter("success")!=null { %>
<html:text name="BEAN_NAME" property="TEXTBOX_NAME" Value="" />
<% } else { %>
<html:text name="BEAN_NAME" property="TEXTBOX_NAME" />

i have made text box in above code using struts, but you can do whatever framework you are using. But the logic will be the same.
[ April 03, 2006: Message edited by: Ish Rawal ]

Ish Rawal<br /> <br />"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster"
Ganesh Jung

Joined: Jul 31, 2003
Posts: 6

Use Double instead of double. null-value in the property will display as blank.

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Thanks Ganesh, it works !!

stalin das

Joined: Sep 21, 2015
Posts: 1
Double will not display the value in the inputtext field but when its get saved in table showing as 0.0.
I agree. Here's the link:
subject: mapping double value to inputText
It's not a secret anymore!