wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "mapping double value to inputText" Watch "mapping double value to inputText" New topic
Author

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.

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

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

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
Greenhorn

Joined: Jul 31, 2003
Posts: 6
Hi,

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

Greetz,
Ganesh
Rajeev Ravindran
Ranch Hand

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

Rajeev.
 
wood burning stoves
 
subject: mapping double value to inputText
 
Similar Threads
Problem using convertNumber for decimal numbers
JSF ValueChange problems and Default method where the form submits to
Confusion about Double.NaN
Can anyboby confirm the result of this Math fn ?
How to create copy/delete buttons for Input Text in JSF