PDA

View Full Version : [CLOSED] Attaching FormPanels using TableLayout



joshb
26 May 2008, 7:33 AM
I've created a ContentPanel that attempts to add two form panels in separate columns, and I get the following Error:


[ERROR] Unable to load module entry point class com.test.client.Loader (see associated exception for details)
java.lang.IllegalStateException: Should only call onAttach when the widget is detached from the browser's document

at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:105)
at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1206)
at com.extjs.gxt.ui.client.widget.Container.doAttachChildren(Container.java:264)
at com.extjs.gxt.ui.client.widget.ContentPanel.doAttachChildren(ContentPanel.java:669)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:111)
at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1206)
at com.extjs.gxt.ui.client.widget.Container.doAttachChildren(Container.java:264)
at com.extjs.gxt.ui.client.widget.ContentPanel.doAttachChildren(ContentPanel.java:669)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:111)
at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1206)
I tried to digg in the source in the Component Class, and figure it is calling something it maybe shouldn't, since the ContentPanel isn't yet attached to the Dom, but wasn't quite able to isolate it.

Here is the Code



package com.test.client;

import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;

public class ComplexForm extends ContentPanel {

FormPanel left;
FormPanel right;

public ComplexForm() {

super();

TableLayout tl = new TableLayout(2);
this.setLayout(tl);

this.setHeading("2 Column Form Panel");
this.setHeight(300);


left = new FormPanel();
right = new FormPanel();


left.setLabelWidth(50);
TextField l1 = new TextField();
l1.setFieldLabel("Lefty1");

left.add(l1);

TableData tdl = new TableData();
tdl.setVerticalAlign( VerticalAlignment.TOP );

TextField l2 = new TextField();
l2.setFieldLabel("Lefty2");

left.add(l2);

this.add(left, tdl);


right.setLabelWidth(250);
TextField r1 = new TextField();
r1.setFieldLabel("Righty Right Right 1");

right.add(l1);


TextField r2 = new TextField();
r2.setFieldLabel("Righty Right Right2");

right.add(r2);

TableData tdr = new TableData();
tdr.setVerticalAlign( VerticalAlignment.TOP );

this.add(right, tdr);
}


}


And My entry point simply does this:



ComplexForm cf = new ComplexForm();

RootPanel.get().add(cf);
Any help would be appreciated,

joshb
26 May 2008, 7:43 AM
Woops. My Bad. Please disregard. Its amazing how one silly character can mess things up. I didn't replace one of my variables, so I was adding a left field to the right panel.



right.add(l1);