PDA

View Full Version : Is ButtonBar mandatory with GXT Buttons?



mramadoss
7 Jul 2008, 11:39 AM
We are in the process of converting from MyGWT 0.52 to GXT. We are using widgets from GWT, GXT, and a few other third party widgets. After compiling to 0 errors, when we execute the application, we encountered the following error:
[ERROR] Unable to load module entry point class com.mycompany.project.client.GxtTest (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError): 'children' is null or not an object
number: -2146823281
description: 'children' is null or not an object
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:443)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeInt(ModuleSpace.java:191)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeInt(JavaScriptHost.java:75)
at com.google.gwt.user.client.DOM.getChildIndex(DOM.java:731)
at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1170)
at com.extjs.gxt.ui.client.widget.button.Button.onAttach(Button.java:201)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:165)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:111)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:165)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:111)

After debugging I find that the GXT button in the panel is added to a buttonbar and then to my panel, I found the window working. When I add the (Gxt) button directly to my verticalpanel, i get the aforementioned error.

Am I forced to use to the ButtonBar whenever I use GXT Buttons? ( I didn't do this in MyGWT).

Thanks,
Mukund

mramadoss
7 Jul 2008, 12:32 PM
Well actually there is more to it. On further debugging, I find that the line which is causing the problem is :
innerPanel.setCellHorizontalAlignment(submitBtn, HasHorizontalAlignment.ALIGN_RIGHT);

Here submitBtn is a Gxt Button Widget and innerPanel is GWT's VerticalPanel. This was working with MyGwt 0.52 but fails during runtime....

darrellmeyer
8 Jul 2008, 6:38 AM
You do not have to use a ButtonBar with GXT Buttons. If you still have problems with 1.0 final code, post some sample code.

mramadoss
8 Jul 2008, 8:19 AM
I tried with GXT 1.0 final version and still encounter problem when I try to do setCellHorizontalAlignment on a GXT button. The problem may exist for other GXT widgets as well. I'm pasting the sample code below.


package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;

import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.button.Button;

/**
* Demonstrates the various button widgets.
*/
public class GxtTest extends Composite implements EntryPoint {

public Button submitBtn = new Button("Login");
final VerticalPanel innerPanel = new VerticalPanel();
final HorizontalPanel outerPanel = new HorizontalPanel();
private HTML html = new HTML("Login");
private Label passLbl = new Label("Password");
private PasswordTextBox passwordTextBox = new PasswordTextBox();

private Label usrnameLbl = new Label("User Name");

private TextBox usrnameTB = new TextBox();
public GxtTest() {
SelectionListener<ComponentEvent> listener = new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
Button btn = (Button) ce.component;
Info.display("Click Event", "The '{0}' button was clicked.", btn.getText());
}
};
innerPanel.add(html);
innerPanel.setCellVerticalAlignment(html, HasVerticalAlignment.ALIGN_TOP);
html.setHeight("20");
innerPanel.setCellHorizontalAlignment(html, HasHorizontalAlignment.ALIGN_CENTER);

innerPanel.add(usrnameLbl);
innerPanel.setCellHorizontalAlignment(usrnameLbl, HasHorizontalAlignment.ALIGN_CENTER);

innerPanel.add(usrnameTB);
innerPanel.setCellHorizontalAlignment(usrnameTB, HasHorizontalAlignment.ALIGN_CENTER);

innerPanel.add(passLbl) ;
innerPanel.setCellHorizontalAlignment(passLbl, HasHorizontalAlignment.ALIGN_CENTER);

innerPanel.add(passwordTextBox);
innerPanel.setCellHorizontalAlignment(passwordTextBox, HasHorizontalAlignment.ALIGN_CENTER);

submitBtn.addSelectionListener(listener);

innerPanel.add(submitBtn);
innerPanel.setCellHorizontalAlignment(submitBtn, HasHorizontalAlignment.ALIGN_RIGHT);

outerPanel.add(innerPanel);

initWidget(outerPanel);
}

public void onModuleLoad() {
RootPanel.get().add(this);
}

}

Running the above code results in the error that I had posted in my first post. However when I comment the following line:
innerPanel.setCellHorizontalAlignment(submitBtn, HasHorizontalAlignment.ALIGN_RIGHT);
the error goes away.

Thanks