package net.helipilot50.stocktrade.client;
import net.helipilot50.stocktrade.model.Customer;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.binding.FieldBinding;
public class CustomerDetailsPanel extends FormPanel {
private Customer customer;
private TextField txtfldCustomerName;
private TextArea txtrAddress;
private NumberField nmbrfldCashBalance;
private TextField txtfldPhoneTextfield;
public CustomerDetailsPanel() {
setHeading("Customer");
txtfldCustomerName = new TextField();
txtfldCustomerName.setName("CustomerName");
add(txtfldCustomerName, new FormData("100%"));
txtfldCustomerName.setFieldLabel("Name");
txtrAddress = new TextArea();
add(txtrAddress, new FormData("100%"));
txtrAddress.setFieldLabel("Address");
this.txtfldPhoneTextfield = new TextField();
add(this.txtfldPhoneTextfield, new FormData("100%"));
this.txtfldPhoneTextfield.setFieldLabel("Phone");
nmbrfldCashBalance = new NumberField();
add(nmbrfldCashBalance, new FormData("100%"));
nmbrfldCashBalance.setFieldLabel("Cash Balance");
if (this.customer != null)
initDataBindings();
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
if (this.customer != null)
initDataBindings();
}
protected void initDataBindings() {
FieldBinding fieldBinding = new FieldBinding(txtfldCustomerName, "customerName");
fieldBinding.bind(customer);
//
FieldBinding fieldBinding_1 = new FieldBinding(txtrAddress, "address");
fieldBinding_1.bind(customer);
//
FieldBinding fieldBinding_2 = new FieldBinding(txtfldPhoneTextfield, "phoneNumber");
fieldBinding_2.bind(customer);
//
FieldBinding fieldBinding_3 = new FieldBinding(nmbrfldCashBalance, "cashBalance");
fieldBinding_3.bind(customer);
}
}