PDA

View Full Version : [FIXED] ComboBox doesn't work with Long attribute



rgpinheiro
2 Jul 2008, 11:44 AM
When I try to set a Long value in display field of a combobox, I can't select the item that I want.
When I set a String value it works fine.

rgpinheiro
3 Jul 2008, 6:35 AM
also, while trying to set the display field with an attribute that belongs to an object of my ModelData ComboBox, the data are not shown correctly.

For example:


public class CorporationComboBox extends GenericComboBox<CorporationDTO> {

public CorporationComboBox(CorporationDTO corporationDTO, String fieldLabel, String displayField) {
super(corporationDTO, fieldLabel, displayField);
}
}
The call that creates the object:


corporateNameComboBox = new CorporationComboBox(insurancePolicyEnterprise.getCorporationDTO(), "Empresa", "entity.corporateName");
GWT 1.5
GXT 1.0 - RC2
hosted browser and Firefox 3
Ubuntu 8.04

http://img388.imageshack.us/img388/5048/comboboxxr2.th.png (http://img388.imageshack.us/my.php?image=comboboxxr2.png)

darrellmeyer
3 Jul 2008, 9:29 AM
First, only one bug per thread please. Second, please include same test code (http://extjs.com/forum/forumdisplay.php?f=31).

rgpinheiro
3 Jul 2008, 10:52 AM
Sorry again... =\

well, here the code for the first bug:



import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.google.gwt.core.client.EntryPoint;

public class Index implements EntryPoint {

private ComboBox<Person> comboBox;
private Person person1;
private FormPanel formPanel;
private Dialog dialog;
private Person person2;

public void onModuleLoad() {

Long i = new Long(3333333);

person1 = new Person();
person1.setId(1);
person1.setName("Rafael");
person1.setPersonCode(i);

person2 = new Person();
person2.setId(2);
person2.setName("Offspring");
person2.setPersonCode(i+1);

ListStore<Person> listPerson = new ListStore<Person>();
listPerson.add(person1);
listPerson.add(person2);

dialog = new Dialog();
dialog.setWidth(400);
dialog.setHeight(200);

formPanel = new FormPanel();
formPanel.setHeaderVisible(false);
formPanel.setFrame(true);
formPanel.setFieldWidth(110);
formPanel.setLabelWidth(100);
formPanel.setButtonAlign(HorizontalAlignment.CENTER);
formPanel.setWidth("100%");

comboBox = new ComboBox<Person>();
comboBox.setStore(listPerson);
comboBox.setDisplayField("personCode");

// with the attribute -name- the combobox works fine
//comboBox.setDisplayField("name");

comboBox.setFieldLabel("Person cod:");

formPanel.add(comboBox);
dialog.add(formPanel);

dialog.show();
}

}


import com.extjs.gxt.ui.client.data.BaseTreeModel;

public class Person extends BaseTreeModel {

private static final long serialVersionUID = -7506205164127602576L;

private int id;
private String name;
private Long personCode;

public Person(){

}

public int getId() {
return get("id");
}
public void setId(int id) {
set("id", id);
}
public String getName() {
return get("name");
}
public void setName(String name) {
set("name", name);
}
public Long getPersonCode() {
return get("personCode");
}
public void setPersonCode(Long personCode) {
set("personCode", personCode);
}

}

darrellmeyer
3 Jul 2008, 12:57 PM
Fix is in SVN for the bug you posted code for.

rgpinheiro
4 Jul 2008, 5:03 AM
Thanks Darrell