You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ted Husted <hu...@apache.org> on 2002/02/04 03:58:59 UTC

Re: Formatting Dates, Integers...

Pesonally, I recommend doing such things in the ActionForm. You can do
them in the page, but that means modifying the page, and placing what is
really business logic in the presentation tier. While it seems we are
talking about how data "looks", formatting it this way or that is really
a business requirement. The part about stuffing the formatted string
into HTML is the presentation tier. The J2EE blueprints call these
helper beans or methods.

Generally, I add a second getter to provide the formatted version. This
does the same thing a tag would do, but is easier to write. The actual
formatting code I would put into a library in the business tier that the
ActionForm method would simply call. So you could add these without
touching your existing methods, and just have the bean:write call these
getters instead. 

Of course, if we are talking about display data, and you already have
beans that render the formatted data, just use those. The ActionForms
are only important for inputting data. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


"Hudayioglu, Fehmi" wrote:
> 
> Hi fellows,
> 
> I have searched the mailing list in hope to find a way to display a number
> in format (e.g:120.200,32). I couldn't find any solution. There were some
> messages proposing to play on the getter and setter methods. But, this is
> not a solution we imagine. Because we have some object properties in the
> Form Bean and their properties can be set by struts directly. So changing
> getter and setter methods requires tons of effort to modify our  data
> classes and form beans which is of course NOT desirable. I also know that
> there is a DateTag library of Jakarta, which is yet in beta release.
> Therefore, my managers (regards to them) don't want to use beta releases.
> They don't want to modify struts tags neither. However, I believe this is
> quite straightforward way (hopefully they will be contended soon).
> 
> So,
> 1. Do you have any clever solution for this common problem?
> 2. What necessary steps should I take in order to add a new Format attribute
> to the form:text and bean:write?
> 2.1 In case, I added necessary methods, how can I guarantee that struts set
> this formatted value to the property. According to my tries, it doesn't set
> them correctly?
> 2.2 How long does an ordinary developer require to modify struts to do so?
> 
> thanks and my best regards,
> fehmi.
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>