Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Formatting Dates and Currency, DynaActionForm  RSS feed

 
ranger
Posts: 17344
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
Posts: 17344
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
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!