View Full Version : Method must be called after the component is rendered

14 May 2010, 1:20 PM
I've got this error whe trying to change DateField field on my panel in constructor or in onRender method. If I try to do same with NumberField field - all ok.

I've found that this was problem for some components -
here (https://www.extjs.com/forum/showthread.php?37715-Help-With-Example-Method-must-be-called-before-the-component-is-rendered&p=344959) or here (http://www.extjs.com/forum/showthread.php?76052-java.lang.AssertionError-Method-must-be-called-after-the-component-is-rendered). In last example it was solved by changing to new version.

Here is stack trace:

00:14:47.453 [ERROR] [appName] Failed to create an instance of 'MyUtils' via deferred binding

java.lang.AssertionError: Method must be called after the component is rendered
at com.extjs.gxt.ui.client.widget.Component.assertAfterRender(Component.java:1500)
at com.extjs.gxt.ui.client.widget.Component.el(Component.java:411)
at com.extjs.gxt.ui.client.widget.form.DateField$1.handleEvent(DateField.java:149)
at com.extjs.gxt.ui.client.widget.form.DateField$1.handleEvent(DateField.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:462)
at com.extjs.gxt.ui.client.widget.DatePicker.setValue(DatePicker.java:488)
at com.extjs.gxt.ui.client.widget.DatePicker.setValue(DatePicker.java:471)
at com.kpb.finutils.client.widgets.BondCalcPanel.<init>(BondCalcPanel.java:66)
at com.kpb.finutils.client.FinanceUtils.<init>(FinanceUtils.java:28)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:422)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:361)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Thread.java:619)

14 May 2010, 1:24 PM
Have you read the bugforum guidelines? Please post a fully working testcase that implements EntryPoint. Moved this to the help forum for now

14 May 2010, 1:45 PM
I guess you are setting the value on the datepicker directly. Is there any reason for it? Set the value on the DateField. I changed the code so that your code does not throw an exception.

14 May 2010, 2:07 PM
Thank you once more.
But any way the problem with editing through datePicker exists. So here is code:

public class ErrorExample implements EntryPoint {
public void onModuleLoad() {
RootPanel.get().add(new Test());

class Test extends LayoutContainer {
private DateField date = new DateField();

protected void onRender(Element parent, int index) {
super.onRender(parent, index);

date.getDatePicker().setValue(new Date());

OS:windows XP
Browser : FF 3.6
GWT: 2.0.3

14 May 2010, 2:10 PM
You dont edit the value through the picker. Simple set the value on the datefield.

As i said. I modified the code so it wont through an exception, but it is the wrong approach.