This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes represent Double as Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "represent Double as "" instead of 0.0 in .jsp page without javascript" Watch "represent Double as "" instead of 0.0 in .jsp page without javascript" New topic
Author

represent Double as "" instead of 0.0 in .jsp page without javascript

Imre Tokai
Ranch Hand

Joined: Jun 04, 2008
Posts: 130
I prepare filling the jsp page with:

SomeForm someForm = new SomeForm();
httpServletRequest.setAttribute("SomeForm", someForm);

SomeForm has the attribute attDoub type double

in .jsp page i have the text field:
<td><html:text property="attDoub" styleId="attDoub" size="14"/></td>

How can i get "" value in stead of 0.0 on loaded page?
Javascript is not allowed!


Regards

P.S.
I tried with value="" but it permanently changes the value of property
Shawn Montague
Greenhorn

Joined: Aug 06, 2008
Posts: 25
What about starting with a String and converting to Double after-the-fact?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I agree with Shawn's suggestion. Struts 1 does not have good support for property types other than String or boolean in ActionForm beans. Another disadvantage of using a double type is that if the user enters a value that will not convert to a double and you redisplay the page, the value will be displayed as "0.0" rather than the actual value entered by the user.


Merrill
Consultant, Sima Solutions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: represent Double as "" instead of 0.0 in .jsp page without javascript
 
Similar Threads
Need help selected text fields visible for particular option from drop down list in JSP(struts)
using Multiple submit buttons.
using logic:equal tag
Struts 1.x, 2, jstl questions
Struts 1 -- Wrong data displaying in my JSP page