Smart GWT MVP pattern

Hi all,

I’m using smartgwt in order to develop an example application and I found following error whit IE when applying MVP pattern.

  1. the SmartGWT version is 2.5 (also 2.4); IE 6-7-8-9
  2. GWT SDK 2.4.0 (also 2.3.0)

Issue:

After creating a new gwt project with eclipse helios i have added smargwt library and <inherits name=“com.smartgwt.SmartGwt”/>. The application run normally.

After that i following gwt Contacts example in order to modify my application whit MVP pattern.
I have two views (similar to each other, less than a label) with 2 button, and when i press one, application make switch to second view.

After that, with IE the problem is try to change view: the following error is showed:

18:04:06.305 [ERROR] [xeniasoccer] 18:04:06.302:TMR9:WARN:Log:Error: ‘Impossibile ottenere il valore della proprietà ‘currentStyle’:null object or undefined’ in http://127.0.0.1:8888/xeniasoccer/sc/modules/ISC_Core.js at line 1873
com.smartgwt.client.core.JsObject$SGWT_WARN: 18:04:06.302:TMR9:WARN:Log:Error: Can not get the value of the ‘currentStyle’: Object invalid or undefined’ in http://127.0.0.1:8888/xeniasoccer/sc/modules/ISC_Core.js at line 1873
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)

I found that the problem is this statement:
container.clear();

in the my presenter method:

public void go(final HasWidgets container) {
bind();
container.clear();
container.add(display.asWidget());
}

if i remove container.clear() (container is RootPanel.get()) the error isn’t showed but the different views are queued on the page.

Any ideas?

Thanks, Vico

Google’s MVP pattern is a pattern for working with core GWT widgets, which lack data binding capabilities. Google has not recommended it as a pattern for working with SmartGWT widgets, which already have built-in support for data binding.

Instead, read the QuickStart Guide to understanding how data binding works in SmartGWT.

Thank for your reply,
but i can’t dismiss MPV pattern. this choice doesn’t depend me.
I would like know if there is a smartgwt problem at api level.
Restructure the entire application, which is not the example, would cost too much, so the choice would be discard smartgwt.
For above problem i’m trying to understand on a simple MVP application.

No, there’s no API problem with SmartGWT. For SmartGWT components, use SmartGWT databinding - it’s simpler and much less code.

In addition, avoid invalid mixing of GWT and SmartGWT components (see FAQ) - in your particular code, calling clear() on a GWT container that contains SmartGWT components is invalid because it destroys the DOM without notifying SmartGWT. Call clear() or destroy() on the SmartGWT components first.

Great, I have modified clear() routine and now it runs. Thanks a lot.

Vico