Search in sources :

Example 1 with Converter

use of com.extjs.gxt.ui.client.binding.Converter in project activityinfo by bedatadriven.

the class LocalDateBinding method create.

public static FieldBinding create(DateField dateField, String datePropertyName) {
    FieldBinding binding = new FieldBinding(dateField, datePropertyName);
    binding.setConverter(new Converter() {

        @Override
        public Object convertModelValue(Object value) {
            if (value == null) {
                return null;
            } else {
                return ((LocalDate) value).atMidnightInMyTimezone();
            }
        }

        @Override
        public Object convertFieldValue(Object value) {
            if (value == null) {
                return null;
            } else {
                Date dateValue = (Date) value;
                return new LocalDate(dateValue);
            }
        }
    });
    return binding;
}
Also used : FieldBinding(com.extjs.gxt.ui.client.binding.FieldBinding) Converter(com.extjs.gxt.ui.client.binding.Converter) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) Date(java.util.Date) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate)

Aggregations

LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)1 Converter (com.extjs.gxt.ui.client.binding.Converter)1 FieldBinding (com.extjs.gxt.ui.client.binding.FieldBinding)1 Date (java.util.Date)1