|
|
|
[
Permlink
| « Hide
]
Philip Luppens - [18/Jul/05 10:14 AM ]
This is a second attempt at a simple date tag; it can format a date by specifying a format="" attribute, or fall back on a general defined property webwork.date. If the nice="yes" attribute is specified, it will try to print out the date in a nice human readable way ("2 hours, 23 minutes ago").
Ack, it should read:
if the nice="true" attribute .. Hi Rainer,
Since the 2.2 upgrade, there are a couple of bugs in the hack I attached. If you want, I can take a look at it tomorrow at work. Basically, the stack lookup method has to be changed, and I think the global resource key wasn't working any more either. I also think we should at not only 2 hours, 2 minutes ago, but also the future: in 2 hours, 2 minutes. Phil,
that would be great... Here is my first part of the implementation... Please have a look and apply your additional changes & ideas. Thanks, Rainer Switched to Component/ComponentTag instead of extending TextTag, added JavaDoc snippets.
Latest version, includes updated DateTagTest.
Philip I assigned it to me so I remember to check it out.
I'll push it back to you after review so you can commit it. Actually, I secretly took it over from Rainer while he wasn't paying attention :-)
I don't have commit rights on the CVS, so go ahead. Suggestion for issue worklfow: Close issue only if code changes are in place.
So if a patch is submitted, someone with CVS access should be assigned the issue so that he is in charge for applying and closing it. So, why not me? :) Err, .. if I told you that I actually meant to change the status to resolved, yet by accident closed it, and because I was afraid the flood of 'issue opened, reassigned, commented, deleted, added', etc .. and finally, I closed it. Then I thought, damn, that thing generates an email message everytime I do something (stupid), so I thought: let's give it a couple of hours ;-)
So, my bad - and yes, Rene, if you see a chance to test/commit it, be my guest :-) Applied Phil's sources to CVS, thanks for submitting.
I have three comments to this fix
#1 I think the log level should be lowerd to WARN if a conversion to java.util.Date fails. #2 A TODO in the unit tests now success so I should have been removed, I'll do that as I have added some test. #3 This is just my personal preference. I do not like automatted code formatter that breaks code into strickt 80 chars per line. So you would see object<dot>method being breaked to a new line. Such as line 187-188: return tp .getText(DATETAG_PROPERTY_PAST, DATETAG_DEFAULT_PAST, args); This is just my personal preference. Can someone please commit this patch ? It allows retrieval of the format attribute value on the ValueStack rather than hardcoded values.
Index: Date.java =================================================================== RCS file: /cvs/webwork/src/java/com/opensymphony/webwork/components/Date.java,v retrieving revision 1.5 diff -u -r1.5 Date.java --- Date.java 18 Mar 2006 16:03:47 -0000 1.5 +++ Date.java 21 Mar 2006 10:23:11 -0000 @@ -38,6 +38,7 @@ * <pre> * <!-- START SNIPPET: example --> * <ww:date name="person.birthday" format="dd/MM/yyyy" /> + * <ww:date name="person.birthday" format="%{getText('some.i18n.key')}" /> * <ww:date name="person.birthday" nice="true" /> * <ww:date name="person.birthday" /> * <!-- END SNIPPET: example --> @@ -196,7 +197,9 @@ // bad date, return a blank instead ? msg = ""; } - + //try to find the format on the stack + if (format != null) + format = findString(format); if (date != null) { TextProvider tp = findProviderInStack(); if (tp != null) { | ||||||||||||||||||||||||||||||||||||||||||||||