gzznhl
4 Jun 2009, 12:35 AM
Hi,
I'm evaluating GXT for use in a fairly large telecomms project, but have run into the following issue (I'm at a critical point in technology selection):
I have a combobox (displaying "lastname, firstname") which on selection binds the selected row to a form. The form is editable, but when I edit either the firstname or last name the edit is not reflected immediately into the combobox.
Then, next, regardless of which row had selected in the combobox and consequently edited in the form panel, when I next pull the combobox down again, after the edit, the firstname and lastname edits are displayed in the list but always for the first row in the combobox (not the row I'd selected and edited). This all looks wrong...is it a bug or am I doing something wrong in the code?
Thanks,
Alan
Here's my code (would appreciate all assistance):
publicclass UserPanel extends ContentPanel {
private ListStore store;
private FormBinding binding;
public UserPanel() {
final CompanyManagementServiceAsync companyManagementService = Registry.get(MobileControl.COMPANY_MANAGEMENT_SERVICE);
//
// Create the proxy for data retrieval
//
RpcProxy proxy = new RpcProxy() {
publicvoid load(Object loadCfg, AsyncCallback cb) {
companyManagementService.getUsers(cb);
}
};
//
// Create the bean loader
//
BeanModelReader<UserBeanModel> reader = new BeanModelReader<UserBeanModel>();
ListLoader loader = new BaseListLoader(proxy, reader);
store = new ListStore<BeanModel>(loader);
//
// Sort on firstname
//
store.sort("firstname", SortDir.ASC);
//
// Create the username combobox
//
final ComboBox combo = new ComboBox();
combo.setFieldLabel("User");
combo.setTriggerAction(TriggerAction.ALL);
combo.setEditable(false);
combo.setStore(store);
combo.addSelectionChangedListener(
new SelectionChangedListener<ModelData>() {
@Override
publicvoid selectionChanged(
SelectionChangedEvent<ModelData> se) {
binding.bind(se.getSelectedItem());
}
});
this.add(combo);
//
// Create the Customer panel
//
FormPanel formPanel = new FormPanel();
formPanel.setHeading("User Details");
formPanel.setFrame(true);
formPanel.setAutoHeight(true);
formPanel.setAutoWidth(true);
TextField<String> username = new TextField<String>();
username.setFieldLabel("Username");
username.setName("username");
formPanel.add(username);
TextField<String> password = new TextField<String>();
password.setFieldLabel("Password");
password.setName("password");
password.setPassword(true);
formPanel.add(password);
TextField<String> firstname = new TextField<String>();
firstname.setFieldLabel("First Name");
firstname.setName("firstname");
formPanel.add(firstname);
TextField<String> lastname = new TextField<String>();
lastname.setFieldLabel("Last Name");
lastname.setName("lastname");
formPanel.add(lastname);
TextField<String> email = new TextField<String>();
email.setFieldLabel("Email Address");
email.setName("email");
email.setAllowBlank(false);
formPanel.add(email);
//
// Create the form bindings
//
binding = new FormBinding(formPanel, true);
binding.addFieldBinding(new FieldBinding(firstname, "firstname"));
binding.addFieldBinding(new FieldBinding(lastname, "lastname"));
binding.autoBind();
binding.setStore(combo.getStore());
this.add(formPanel);
}
}
I'm evaluating GXT for use in a fairly large telecomms project, but have run into the following issue (I'm at a critical point in technology selection):
I have a combobox (displaying "lastname, firstname") which on selection binds the selected row to a form. The form is editable, but when I edit either the firstname or last name the edit is not reflected immediately into the combobox.
Then, next, regardless of which row had selected in the combobox and consequently edited in the form panel, when I next pull the combobox down again, after the edit, the firstname and lastname edits are displayed in the list but always for the first row in the combobox (not the row I'd selected and edited). This all looks wrong...is it a bug or am I doing something wrong in the code?
Thanks,
Alan
Here's my code (would appreciate all assistance):
publicclass UserPanel extends ContentPanel {
private ListStore store;
private FormBinding binding;
public UserPanel() {
final CompanyManagementServiceAsync companyManagementService = Registry.get(MobileControl.COMPANY_MANAGEMENT_SERVICE);
//
// Create the proxy for data retrieval
//
RpcProxy proxy = new RpcProxy() {
publicvoid load(Object loadCfg, AsyncCallback cb) {
companyManagementService.getUsers(cb);
}
};
//
// Create the bean loader
//
BeanModelReader<UserBeanModel> reader = new BeanModelReader<UserBeanModel>();
ListLoader loader = new BaseListLoader(proxy, reader);
store = new ListStore<BeanModel>(loader);
//
// Sort on firstname
//
store.sort("firstname", SortDir.ASC);
//
// Create the username combobox
//
final ComboBox combo = new ComboBox();
combo.setFieldLabel("User");
combo.setTriggerAction(TriggerAction.ALL);
combo.setEditable(false);
combo.setStore(store);
combo.addSelectionChangedListener(
new SelectionChangedListener<ModelData>() {
@Override
publicvoid selectionChanged(
SelectionChangedEvent<ModelData> se) {
binding.bind(se.getSelectedItem());
}
});
this.add(combo);
//
// Create the Customer panel
//
FormPanel formPanel = new FormPanel();
formPanel.setHeading("User Details");
formPanel.setFrame(true);
formPanel.setAutoHeight(true);
formPanel.setAutoWidth(true);
TextField<String> username = new TextField<String>();
username.setFieldLabel("Username");
username.setName("username");
formPanel.add(username);
TextField<String> password = new TextField<String>();
password.setFieldLabel("Password");
password.setName("password");
password.setPassword(true);
formPanel.add(password);
TextField<String> firstname = new TextField<String>();
firstname.setFieldLabel("First Name");
firstname.setName("firstname");
formPanel.add(firstname);
TextField<String> lastname = new TextField<String>();
lastname.setFieldLabel("Last Name");
lastname.setName("lastname");
formPanel.add(lastname);
TextField<String> email = new TextField<String>();
email.setFieldLabel("Email Address");
email.setName("email");
email.setAllowBlank(false);
formPanel.add(email);
//
// Create the form bindings
//
binding = new FormBinding(formPanel, true);
binding.addFieldBinding(new FieldBinding(firstname, "firstname"));
binding.addFieldBinding(new FieldBinding(lastname, "lastname"));
binding.autoBind();
binding.setStore(combo.getStore());
this.add(formPanel);
}
}