Hi,
Thanks for that solution! After finding the DateLabel in the API, I
extended PropertyColumn to this class:
public class DatePropertyColumn extends PropertyColumn
{
private static final long serialVersionUID = 1L;
private DateConverter converter;
public DatePropertyColumn(IModel displayModel, String
sortProperty,
String propertyExpression, DateConverter converter)
{
super(displayModel, sortProperty, propertyExpression);
this.converter = converter;
}
@SuppressWarnings("unchecked")
@Override
public void populateItem(Item> item, String
componentId, IModel rowModel)
{
item.add(new DateLabel(componentId, (IModel)
createLabelModel(rowModel), converter));
}
}
I had to create my own extension of PatternDateConverter to deal with
java.sql.Timestamp values in my model objects:
public class TimestampConverter extends PatternDateConverter
{
private static final long serialVersionUID = 1L;
public TimestampConverter(String datePattern)
{
super(datePattern, false);
}
@Override
public Timestamp convertToObject(String value, Locale locale)
{
Date time = super.convertToObject(value, locale);
return new Timestamp(time.getTime());
}
}
and this is what is passed into the constructur of the
DatePropertyColumn.
Shelli
-Original Message-
From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com]
On Behalf Of James Carman
Sent: Monday, October 18, 2010 1:24 PM
To: users@wicket.apache.org
Subject: Re: Format Date for PropertyColumn/DefaultDataTable
We use this for formatting dates, numbers, etc.:
public class MessageFormatColumn extends PropertyColumn
{
private final String pattern;
public MessageFormatColumn(IModel displayModel, String
propertyExpression, String pattern)
{
super(displayModel, propertyExpression);
this.pattern = pattern;
}
public MessageFormatColumn(IModel displayModel, String
sortProperty, String propertyExpression, String pattern)
{
super(displayModel, sortProperty, propertyExpression);
this.pattern = pattern;
}
@Override
protected IModel createLabelModel(IModel itemModel)
{
IModel superModel = super.createLabelModel(itemModel);
return new Model(MessageFormat.format(pattern,
superModel.getObject()));
}
}
On Mon, Oct 18, 2010 at 1:33 PM, Shelli Orton
wrote:
> Hi,
>
> Is there a way to apply a DateConverter to a PropertyColumn used in a
> DefaultDataTable (and AjaxFallbackDefaultDataTable)?
>
> Thanks!
>
> Shelli
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org