PDA

View Full Version : Assertion Error



pvr_ramana
18 Mar 2009, 10:44 PM
Hi I am novice and have the following code and when i try to call w_droploans method for second time i get the following error:

Appreciate if any one could point out what could be going wrong?

[ERROR] Uncaught exception escaped
java.lang.AssertionError: Method must be called before the component is rendered
at com.extjs.gxt.ui.client.widget.Component.assertPreRender(Component.java:1216)
at com.extjs.gxt.ui.client.widget.ContentPanel.setCollapsible(ContentPanel.java:581)
at com.wellsfargo.client.GtkDemo.w_droploans(GtkDemo.java:207)
at com.wellsfargo.client.GtkDemo.access$0(GtkDemo.java:195)
at com.wellsfargo.client.GtkDemo$2.componentSelected(GtkDemo.java:116)
at com.wellsfargo.client.GtkDemo$2.componentSelected(GtkDemo.java:1)


Heres the code:



import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.StatusBar;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.custom.ThemeSelector;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.FileUploadField;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SplitToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;


/**
* Entry point classes define <code>onModuleLoad()</code>.
**/
public class GtkDemo extends LayoutContainer implements EntryPoint {

ToolBar toolBar = new ToolBar();

Menu menu = new Menu();

ContentPanel cPanel = new ContentPanel();

LayoutContainer pageContainer = new LayoutContainer();

ContentPanel cp = new ContentPanel();
FormPanel panel = new FormPanel();
Viewport viewport = new Viewport();

ContentPanel north = new ContentPanel();
ContentPanel center = new ContentPanel();
/*ContentPanel west = new ContentPanel();
ContentPanel east = new ContentPanel();*/
ContentPanel south = new ContentPanel();

StatusBar appSBar = new StatusBar();
FormPanel asteraImportFP = new FormPanel();

/**
* This is the entry point method.
*/
public void onModuleLoad() {

final BorderLayout layout = new BorderLayout();
viewport.setLayout(layout);

center.setHeaderVisible(false);
center.setScrollMode(Scroll.AUTOX);
center.setBodyBorder(false);
center.setBorders(false);
BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.setMargins(new Margins(0, 0, 0, 0));

BorderLayoutData northData = new BorderLayoutData(LayoutRegion.NORTH,60);
Html h = new Html("<h1>SMS Windows</h1>");
h.setStyleName("header");


north.add(h);
north.setHeaderVisible(false);
north.setBorders(false);
north.setBodyBorder(false);
northData.setSize(57);
northData.setCollapsible(false);
northData.setFloatable(false);
northData.setHideCollapseTool(false);
northData.setSplit(false);
northData.setMargins(new Margins(0, 0, 0, 0));


SplitToolItem splitItem = new SplitToolItem("Windows");
//splitItem.setIconStyle("icon-list-items");

menu.add(new MenuItem("w_astera_pool_import",
new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
w_astera_pool_import();
}
}));
menu.add(new MenuItem("w_allocate_new"));
menu.add(new MenuItem("w_droploans",
new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
w_droploans();
}
}));

splitItem.setMenu(menu);

toolBar.add(splitItem);
toolBar.add(new FillToolItem());
toolBar.add(new AdapterToolItem(new ThemeSelector()));
north.add(toolBar);

/*BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
westData.setSplit(true);
westData.setCollapsible(true);
westData.setMargins(new Margins(5));

BorderLayoutData eastData = new BorderLayoutData(LayoutRegion.EAST, 150);
eastData.setSplit(true);
eastData.setCollapsible(true);
eastData.setMargins(new Margins(5)); */

BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 25);
southData.setSplit(true);
southData.setCollapsible(true);
southData.setFloatable(true);
southData.setMargins(new Margins(0, 0, 0, 0));

south.setHeaderVisible(false);
south.setBodyBorder(false);
south.setBorders(false);
appSBar.addStyleName("statusBar");
//appSBar.showBusy("Ready");
south.add(appSBar);

viewport.add(north, northData);
viewport.add(center, centerData);

/*viewport.add(west, westData);
viewport.add(east, eastData); */
viewport.add(south, southData);

RootPanel.get().add(viewport);
}

protected void w_astera_pool_import() {
if(center.getItems().size() > 0 ) {
center.removeAll();
}
FileUploadField file = new FileUploadField();
file.setAllowBlank(false);
file.setFieldLabel("File");
asteraImportFP.add(file);

Button btn = new Button("Import");
btn.addSelectionListener(new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce) {
if (!asteraImportFP.isValid()) {
return;
}

// normally would submit the form but for example no server set up to
// handle the post
// panel.submit();

MessageBox.info("Action", "You file was uploaded", null);
}
});
asteraImportFP.addButton(btn);
asteraImportFP.setStyleAttribute("margin", "10px");
//asteraImportFP.setWidth(350);
//asteraImportFP.setHeight(350);
center.add(asteraImportFP);
center.layout();


}

private void w_droploans() {

if (center.getItems().size() > 0) {
for (int i = 0; i < center.getItemCount(); i++) {
center.getItem(i).removeFromParent();
}
/*center.removeAll();*/
}
FormData formData = new FormData("100%");

//panel.setFrame(true);
panel.setIconStyle("icon-form");
panel.setCollapsible(true);
panel.setHeading("FormPanel");

panel.setSize(470, -1);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setLayout(new FlowLayout());

LayoutContainer main = new LayoutContainer();
main.setLayout(new ColumnLayout());

LayoutContainer left = new LayoutContainer();

FormLayout layout = new FormLayout();
layout.setLabelAlign(LabelAlign.TOP);
left.setLayout(layout);

TextField<String> first = new TextField<String>();
first.setFieldLabel("First Name");
left.add(first, formData);

TextField<String> company = new TextField<String>();
company.setFieldLabel("Company");
left.add(company, formData);

DateField birthday = new DateField();
birthday.setFieldLabel("Birthday");
left.add(birthday, formData);

LayoutContainer right = new LayoutContainer();

layout = new FormLayout();
layout.setLabelAlign(LabelAlign.TOP);
right.setLayout(layout);

TextField<String> last = new TextField<String>();
last.setFieldLabel("Last");
right.add(last, formData);

TextField<String> email = new TextField<String>();
email.setFieldLabel("Email");
right.add(email, formData);

Radio radio1 = new Radio();
radio1.setBoxLabel("Yes");

Radio radio2 = new Radio();
radio2.setBoxLabel("No");

RadioGroup group = new RadioGroup();
group.setFieldLabel("Ext GWT User");
group.add(radio1);
group.add(radio2);
right.add(group);

main.add(left, new ColumnData(.5));
main.add(right, new ColumnData(.5));

panel.add(main);

LayoutContainer area = new LayoutContainer();
area.setStyleAttribute("padding", "0 10px 5px 10px");

layout = new FormLayout();
layout.setLabelAlign(LabelAlign.TOP);
layout.setPadding(0);
area.setLayout(layout);

TextArea a = new TextArea();
a.setFieldLabel("Comment");

area.add(a, formData);

panel.add(area);

panel.addButton(new Button("Cancel"));
panel.addButton(new Button("Submit"));

//cp.add(panel);
panel.setPosition(10, 10);

center.add(panel);
center.layout();


}

}