This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply 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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: mapping double value to inputText
 
Similar Threads
JSF ValueChange problems and Default method where the form submits to
How to create copy/delete buttons for Input Text in JSF
Problem using convertNumber for decimal numbers
Confusion about Double.NaN
Can anyboby confirm the result of this Math fn ?