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]>--
С уважением,
Дмитрий Гусев

Reply via email to