Date conversions in Java are hugely ugly.  Are you sure there isn't a
time zone issue involved with this coercion?  Are you sure you want to
see a large number in your URL rather than something that looks like a
Date?

On Fri, Oct 17, 2008 at 1:44 AM, Dmitry Gusev <[EMAIL PROTECTED]> wrote:
> It would be great to implement Date type coertion out-of-the-box through it
> milliseconds representation.
>
> Currently I have to contribute the coertion to my app module:
>
>    public static void
> contributeTypeCoercer(Configuration<CoercionTuple<Long, Date>>
> configuration) {
>        Coercion<Long, Date> coercion = new Coercion<Long, Date>() {
>            public Date coerce(Long input) {
>                Calendar calendar = Calendar.getInstance();
>                calendar.setTimeInMillis(input);
>                return calendar.getTime();
>            }
>        };
>
>        configuration.add(new CoercionTuple<Long, Date>(Long.class,
> Date.class,
>                coercion));
>    }
>
>
> Passing parameters to pagelink component example:
>
> <t:pagelink t:id="edit" page="curriculum/holidays/edit"
> context="holiday.date.time">Edit</t:pagelink>
>
> ---
>
> public class Holiday {
> ...
>    public Date getDate() {
>        return date;
>    }
>    public void setDate(Date date) {
>        this.date = date;
>    }
> ...
> }
>
> ---
>
> And on the Edit page activation/deactivation methods looks like:
>
>    public void onActivate(Date date) {
>        this.date = date;
>        // ...
>    }
>
>    public Date onPassivate() {
>        return date;
>    }
>
> ---
>
> Having Date type coercion support out-of-the-box will let me pass Date
> parameters directly (without invoking Date.getTime() on the actual parameter
> instance).
>
>
>
> <[email protected]>--
> С уважением,
> Дмитрий Гусев
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

Reply via email to