Nice. Where can an jar be downloaded for this?
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/wqdata/wqdata/src/java/shared/org_apache_commons/util/



tia, .V

Ted Husted wrote:
Joe Germuska wrote:
 > I'm still not completely convinced that the best solution isn't to
 > write your own ActionForm class that has two properties, 'date' and
 > 'dateAsString' (or whatever you want to call them) and behind the
 > scenes, when one of the properties simply sets and returns a data
 > member, and the other parses and formats values.

+1

IMHO, this problem is outside both the scope of Struts and ConvertUtils.

There are myriad ways to handle expressions of date and time. Enough that they deserve their own UI class (or classes). The Java libraries provide all the functionality most of us need. The trick, as Joe pointed out, is to put that functionality behind a facade. Especially when you get to as many use-cases as have been enumerated here.

IMHO, the solution is not to push the work off onto the tags or onto the framework, but to centralize it in your own date handler object that can be extended to do what you need it to do.

After three years, we all have working solutions to this problem. Most, I would hazard to guess, are variations of Joe's approach. IMHO, work on this subject is best directed at a better date-handling object (or facade), that could be used by Struts or any other presentation application.

Right now, I'm using a DateDisplay object to handle displaying dates in drop-down boxes and converting it back and forth:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/wqdata/wqdata/src/java/shared/org_apache_commons/util/


There are also some date/time/calendaring handling utilities under development in Commons Lang:


http://cvs.apache.org/viewcvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/


The way I approach this problem is by defining a date handling class (or classes) that can talk to Struts and can also talk to the controller or your business classes. If a date need to be accepted in one format and presented in another, it should the job if this class to handle any conversions. Or, if you need to provide the Date in different binary flavors (util, sql), the class could do that tIn this way it can be used not only with the Struts tags but with JSLT tags and other presentation devices.


I think in the end, we will all be using UI components that make such objects easier to plug into frameworks like Struts, but such components will need objects like these to do the dirty work.

IMHO, this is the most Agile approach of all, since it is easy to implement and test, and can be reused time and again.

-Ted.



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to