Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Imre Tokai
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about starting with a String and converting to Double after-the-fact?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!