View Full Version : [FIXED] problem with the rendering order (in layout())

20 Aug 2008, 5:11 AM
I've come across a bug in the order in which a call to layout() (on a FormPanel - I have not tryed to replicate this with anything else) renders the element in a very unintuitive manner. The problem is as follows:
- some TextField objects are added to a FormPanel and then layout() is called
- another TextField is inserted (with insert()) into the FormPanel and layout is called again
- at first glance, this would simply add the last TextField at the position it has been inserted into, and rerender the panel; this is however NOT what happens: the TextField is rendered as THE LAST element in the panel, no matter where it has been inserted; this should evidently not be the case

- the only sollution (more a crude workaround than sollution) I can see (havn't tried this yet) is to add some other FormPanels to that panel and simply add the TextFields in that panel rather than in the larger panel. This means that a lot of other panels have to be added so that a corect layout can be maintained, which is not a good thing.

This is the test case:

package com.extjs.gxt.main.client.service.testing;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class Test implements EntryPoint {
private final ContentPanel mainPanel;

public Test(){
this.mainPanel = new ContentPanel();

public void onModuleLoad() {
Viewport v = new Viewport();
v.add( this.mainPanel );
RootPanel.get().add( v);


FormPanel form = new FormPanel();
TextField<String> tf1 = new TextField<String>();
tf1.setFieldLabel( "Label1" );
TextField<String> tf2 = new TextField<String>();
tf2.setFieldLabel( "Label2" );
TextField<String> tf3 = new TextField<String>();
tf3.setFieldLabel( "Label3" );
TextField<String> tf4 = new TextField<String>();
tf4.setFieldLabel( "Label4" );


this.mainPanel.layout(); //do layout here


this.mainPanel.layout(); //add it and do another layout


20 Aug 2008, 4:46 PM
There first layout call is not needed and the code will work without it. There was a bug stopping your code from working that has been fixed. The fix is in SVN.

20 Aug 2008, 10:28 PM
No, the first call to layout was not necessary of course. I added it just to better illustrate the problem.

With the call, the order or the rendered text fields is:
tf1, tf2, tf3, tf4
and without it, the order is:
tf1, tf4, tf2, tf3.

Good to hear about the fix.
Thank you for your answer.