• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Formatting Dates and Currency, DynaActionForm

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic