TimeFieldBinding.java :  » Ajax » ext-gwt » com » extjs » gxt » ui » client » binding » Java Open Source

Java Open Source » Ajax » ext gwt 
ext gwt » com » extjs » gxt » ui » client » binding » TimeFieldBinding.java
/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
package com.extjs.gxt.ui.client.binding;

import java.util.Date;

import com.extjs.gxt.ui.client.widget.form.Time;
import com.extjs.gxt.ui.client.widget.form.TimeField;

/**
 * A specialized binding that automatically handles data conversion when dates
 * are bound to a time field.
 * 
 * @see TimeField
 */
public class TimeFieldBinding extends FieldBinding {

  protected TimeField timeField;

  /**
   * Creates a new time field binding instance.
   * 
   * @param field the time field
   * @param property the property name
   */
  public TimeFieldBinding(TimeField field, String property) {
    super(field, property);
    this.timeField = field;
  }

  @Override
  protected Object onConvertFieldValue(Object value) {
    if (value == null) {
      return null;
    }
    Time time = (Time) value;
    return time.getDate();
  }

  @Override
  protected Object onConvertModelValue(Object value) {
    if (value == null) {
      return null;
    }
    Date date = (Date) value;
    return timeField.findModel(date);
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.