Is it necessary that the properties of a form bean be of the type String? What happens if I use integer or float or for that matter anything other than String? I tried using integer and it worked fine but Ive read in quite a few books and articles that the properties of a form bean must be String. What problems can i face if i use anything other than String? Is there an explanatory answer to "why use String"?
The biggest problem with using non-Strings in an ActionForm is with validation. Let's say you have an html:text tag on your JSP and the property is an integer. What happens if the user enters something other than a valid integer in that field? When Struts executes the setter for that field, it will throw a number Format exception. Even if you have server-side validation logic to check the field, When Struts redisplays the page, the field will show zero instead of the invalid data the user actually entered.
If you have a field that is read-only, then I see no problem with declaring it as a non-String in the ActionForm. You can even format it using the format property of bean:write.