Does this help?

        
http://jumpstart.doublenegative.com.au/jumpstart/examples/lang/typecoercers

Geoff

On 13/11/2012, at 6:11 AM, bhorvat wrote:

> I would like to add Joda Time for the Type Coerection but I am not sure how. 
> 
> I have the following eventlink that I would like to implement
> 
> <t:eventlink t:event="showWeekHour" t:context="currentWeek" zone="zoneHours"
>> 
>           Click For Week View                 
> </t:eventlink>
> 
> And the method that handles this would be
> 
>    @OnEvent("showWeekHour")
>    public void selectWeek(LocalDate week) {
>        selectedWeek = week;
>        initialize();
>        ajaxResponseRenderer.addRender("zoneHours", zoneHours);
>    }
> 
> The type coercer 
> 
> @Contribute(TypeCoercer.class)
>    public static void contributeJodaDates(Configuration<CoercionTuple>
> configuration) {
>        configuration.add(new CoercionTuple<java.util.Date,
> DateMidnight>(java.util.Date.class, DateMidnight.class,
>                new Coercion<java.util.Date, DateMidnight>() {
>                    @Override
>                    public DateMidnight coerce(java.util.Date input) {
>                        return new DateMidnight(input);
>                    }
>                }));
> 
>        configuration.add(new CoercionTuple<DateMidnight,
> java.util.Date>(DateMidnight.class, java.util.Date.class,
>                new Coercion<DateMidnight, java.util.Date>() {
>                    @Override
>                    public java.util.Date coerce(DateMidnight input) {
>                        return input.toDate();
>                    }
>                }));
> 
>        configuration.add(new CoercionTuple<java.util.Date,
> LocalDate>(java.util.Date.class, LocalDate.class,
>                new Coercion<java.util.Date, LocalDate>() {
>                    @Override
>                    public LocalDate coerce(java.util.Date input) {
>                        return new LocalDate(input);
>                    }
>                }));
> 
>        configuration.add(new CoercionTuple<LocalDate,
> java.util.Date>(LocalDate.class, java.util.Date.class,
>                new Coercion<LocalDate, java.util.Date>() {
>                    @Override
>                    public java.util.Date coerce(LocalDate input) {
>                        return input.toDate();
>                    }
>                }));
>    }
> 
> However this doesnt really work. I am sure it is a trivial mistake but I
> have no idea how to solve it. 
> 
> I guess that I could pass the long into the event and then implement
> coercion from long to the joda time, but I am not sure if this is the right
> way and if it is possible as well.
> 
> cheers 
> 
> 
> 
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/Type-Coercer-for-Joda-Time-tp5717942.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to