Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Formatting Dates and Currency, DynaActionForm  RSS feed

 
ranger
Sheriff
Posts: 17314
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I just read in Jakarta Pitfalls, by Riley, that you can create a Formatter abstract base class that has a getFormatter factory method, and a format method that will be abstract. Then you can have sublasses that override the format method and formats the String to be a Date or Currency or what ever, and you have one for each type.
OK, I didn't need to explain what I read, plus I read it late last night, and can't remember it completely. But another base class will extend ActionForm and well the design basically by using ActionForm directly will not allow this solution to work with a DynaActionForm class defined in your struts-config.xml
Does anyone know of a way of formatting the data you get and send to HTML forms, while still using DynaActionForms?
And, this is an HTML question and would probably be better in the HTML/JAvascript forum, but if I post my second question there then it would almost be a duplicate post and all the world would descend upon me. OK, here's the question, is there a way to have the HTML form only allow certain entries. Like if you have a number field on the form, and you don't want to allow you user to enter Characters.
Thanks
Mark
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mark,
you may want to investigate one of the following, depending on your needs:
- look at <i18n> tag, maybe write your own, which has to do with messageresource and locales.
- look at the commons lang package from apache. That offers lots of displaying techniques
regards,
friso
 
Mark Spritzler
ranger
Sheriff
Posts: 17314
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the commons class, it has formatters, which I think might match the Formatter class that was in the pitfalls book. However, this will still mean that you can't use the DynaActionForm, because you will need to write an ActionForm class that will utilize these classes.
Also it won't make a TextField in an HTML form stop users from entering wrong types of data.
Thanks
Mark
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!