Hi,
i have got two problem, using a ComboBox on a TabPanel.
It's quite simple. On a simple TabPanel i add two tab's.
The first one with a textfield and the second one with the Combobox.
The ComboBox has an attacht store.
First, if i start this simple app, there is a cpu load of 20% (on my
machine) and the app is comsumpting memory.
Second, i can't change the text of the second tab. There is no error
but the changing will not be displayed. (Lazy loading problem?)
If i switch to the panel with the Combobox the cpu load will drop to 0
and everything is alright. Now i can switch between both panels
without any problems.
If i change the two panel, first adding the combobox panel and then
the textfield, everything is working.
Some code for this:
package de.mcs.gwt.test.client;
import java.util.ArrayList;
import java.util.List;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.data.ArrayReader;
import com.gwtext.client.data.DataProxy;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.MemoryProxy;
import com.gwtext.client.data.ObjectFieldDef;
import com.gwtext.client.data.Reader;
import com.gwtext.client.data.Record;
import com.gwtext.client.data.RecordDef;
import com.gwtext.client.data.Store;
import com.gwtext.client.data.StringFieldDef;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.ComboBox;
import com.gwtext.client.widgets.form.FieldSet;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
/**
* @author Jan Thomae
*/
public class LoginFrameControl extends Panel {
class UnitTO {
private String name;
private String displayName;
private String reference;
public UnitTO(final String displayName, final String name,
final String reference) {
this.displayName = displayName;
this.name = name;
this.reference = reference;
}
}
private ComboBox unitBox;
private TextField loginField;
private FormPanel loginPanel;
private FieldSet loginData;
private FormPanel settingPanel;
private FieldSet extendedSettings;
private Button loginButton;
private ArrayList<UnitTO> unitList;
public LoginFrameControl() {
unitList = new ArrayList<UnitTO>();
UnitTO unit = new UnitTO("Unit1", "Unit1", "Unit1");
unitList.add(unit);
unit = new UnitTO("Unit2", "Unit2", "Unit2");
unitList.add(unit);
createContent();
}
private void createContent() {
TabPanel tabPanel = new TabPanel();
tabPanel.setBorder(true);
tabPanel.setHeader(false);
tabPanel.setResizeTabs(true);
tabPanel.setMinTabWidth(145);
tabPanel.setEnableTabScroll(false);
tabPanel.setWidth(360);
tabPanel.setHeight(230);
tabPanel.setActiveTab(0);
tabPanel.addClass("loginPanel");
loginPanel = new FormPanel();
loginPanel.setBorder(false);
loginPanel.setFrame(true);
loginPanel.setPaddings(10);
loginData = new FieldSet();
loginField = new TextField();
loginField.setValidateOnBlur(false);
loginField.setValidationEvent(false);
// loginField.setValue(controller.getUsername());
loginField.focus();
loginData.add(loginField);
loginPanel.add(loginData);
settingPanel = new FormPanel();
settingPanel.setBorder(false);
settingPanel.setFrame(true);
settingPanel.setPaddings(10);
extendedSettings = new FieldSet();
unitBox = new ComboBox();
unitBox.setEditable(false);
unitBox.setForceSelection(true);
unitBox.setDisplayField("displayName");
unitBox.setMode(ComboBox.LOCAL);
unitBox.setValueField("reference");
unitBox.setStore(new Store(createReader()));
unitBox.setLazyRender(false);
// unitBox.setTriggerAction(ComboBox.ALL);
unitBox.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int
i) {
// controller.setSelectedUnit((UnitTO)
record.getAsObject("data"));
}
});
extendedSettings.add(unitBox);
settingPanel.add(extendedSettings);
tabPanel.add(loginPanel);
tabPanel.add(settingPanel);
loginButton = new Button();
loginButton.addListener(new ButtonListenerAdapter() {
public void onClick(Button button, EventObject
eventObject) {
login(loginField);
}
});
tabPanel.addButton(loginButton);
add(tabPanel);
updateNLSText();
updateUnitBox(unitList);
}
private void updateNLSText() {
loginPanel.setTitle(Translator.translate("TAB_LOGIN"));
loginData.setTitle(Translator.translate
("LoginData.LOGINDATA"));
settingPanel.setTitle(Translator.translate("TAB_EXTENDED"));
loginField.setLabel(Translator.translate("LoginData.USER"));
extendedSettings.setTitle(Translator.translate
("Extended.EXTENDED_SETTINGS"));
unitBox.setLabel(Translator.translate("Extended.UNIT"));
loginButton.setText(Translator.translate("LOGIN"));
doLayout(true);
}
private void updateUnitBox(List<UnitTO> units) {
unitBox.getStore().setDataProxy(createProxy((List<UnitTO>)
units));
unitBox.getStore().reload();
if (unitBox.getStore().getCount() > 1) {
unitBox.setVisible(true);
} else {
unitBox.setVisible(false);
}
updateSelectedUnit();
}
private void updateSelectedUnit() {
unitBox.setValue(unitList.get(0).displayName);
}
private DataProxy createProxy(List<UnitTO> data) {
Object[][] objects = new Object[data.size()][];
for (int i = 0; i < data.size(); i++) {
UnitTO item = data.get(i);
objects[i] = new Object[] {item.displayName,
item.reference, item};
}
return new MemoryProxy(objects);
}
private Reader createReader() {
return new ArrayReader(new RecordDef(new FieldDef[] {new
StringFieldDef("displayName"),
new StringFieldDef("reference"), new ObjectFieldDef
("data")}));
}
private void login(final TextField loginField) {
}
}
bye
Willie
--
You received this message because you are subscribed to the Google Groups
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/gwt-ext?hl=en.