You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Michael Nelson <th...@mailinator.com> on 2010/05/20 22:40:08 UTC
Re: DataTable Generics
/**
* Useful for columns in a DataTable where a date is desired.
*
* @author igorVaynberg - Wicket threads.
*
*/
public class DatePropertyColumn<T> extends PropertyColumn<T> {
private static final long serialVersionUID = 1L;
private final DateFormat dateFormat = DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.SHORT, HelpCenterSession.get()
.getLocale());
public DatePropertyColumn(IModel<String> displayModel, String
propertyExpression) {
super(displayModel, propertyExpression);
}
public DatePropertyColumn(IModel<String> displayModel, String sortProperty,
String propertyExpression) {
super(displayModel, sortProperty, propertyExpression);
}
@Override
protected IModel<String> createLabelModel(IModel<T> embeddedModel) {
final IModel<?> prop = super.createLabelModel(embeddedModel);
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
Date date = (Date) prop.getObject();
return dateFormat.format(date);
}
};
}
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-Generics-tp1908637p2225283.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.