Laugh10704
15 May 2009, 9:20 AM
Consider the following simple code:
public class MyTest implements EntryPoint {
public void onModuleLoad() {
Viewport port = new Viewport();
port.setLayout(new FitLayout());
FormPanel panel = new FormPanel();
for (int i = 0; i < 30; i++) {
final SimpleComboBox box = new SimpleComboBox();
box.add("test");
box.setFieldLabel("somebox " + i);
box.setValue(box.getStore().getAt(0));
panel.add(box, new FormData("100%"));
}
port.add(panel);
RootPanel.get().add(port);
}
}
The above code generates 30 combo boxes, but pre-selects the value by calling box.getStore().getAt(0).
It works and renders fine in the hosted browser and IE, but in Firefox you will "see" the page render - the boxes will start short then very slowly start expanding to fit the width of the screen.
I guess the question is, how does one pre-select a value for a field and not have this rendering problem in Firefox? I tried doing the following:
final SimpleComboBox box = new SimpleComboBox();
box.addListener(Events.AfterLayout, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
box.setValue(box.getStore().getAt(0));
}
});
box.add("test");
box.setFieldLabel("somebox " + i);
but the AfterLayout function is never called.
Thanks!
public class MyTest implements EntryPoint {
public void onModuleLoad() {
Viewport port = new Viewport();
port.setLayout(new FitLayout());
FormPanel panel = new FormPanel();
for (int i = 0; i < 30; i++) {
final SimpleComboBox box = new SimpleComboBox();
box.add("test");
box.setFieldLabel("somebox " + i);
box.setValue(box.getStore().getAt(0));
panel.add(box, new FormData("100%"));
}
port.add(panel);
RootPanel.get().add(port);
}
}
The above code generates 30 combo boxes, but pre-selects the value by calling box.getStore().getAt(0).
It works and renders fine in the hosted browser and IE, but in Firefox you will "see" the page render - the boxes will start short then very slowly start expanding to fit the width of the screen.
I guess the question is, how does one pre-select a value for a field and not have this rendering problem in Firefox? I tried doing the following:
final SimpleComboBox box = new SimpleComboBox();
box.addListener(Events.AfterLayout, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
box.setValue(box.getStore().getAt(0));
}
});
box.add("test");
box.setFieldLabel("somebox " + i);
but the AfterLayout function is never called.
Thanks!