tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry Gusev" <dmitry.gu...@gmail.com>
Subject Request for introducing java.util.Date type coercion out-of-the-box
Date Fri, 17 Oct 2008 08:44:16 GMT
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).



<dev@tapestry.apache.org>--
С уважением,
Дмитрий Гусев
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message