aspose file tools*
The moose likes Struts and the fly likes Formatting Dates and Currency, DynaActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Formatting Dates and Currency, DynaActionForm" Watch "Formatting Dates and Currency, DynaActionForm" New topic
Author

Formatting Dates and Currency, DynaActionForm

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
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


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

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
 
wood burning stoves
 
subject: Formatting Dates and Currency, DynaActionForm