PDA

View Full Version : GXT and native methods in Ext class



fother
6 Aug 2009, 5:49 AM
native methos...

"This type of code is difficult to maintain, can lead to cross browser incompatibilities, and prevents the GWT compiler from checking and optimizing your code."

http://www.zackgrossbart.com/hackito/antiptrn-gwt/

this its true?

sven
6 Aug 2009, 6:24 AM
That code is highly optimited, is very good mantainable and cant be writtin without native code.

TheBuzzer
6 Aug 2009, 8:47 AM
That code is highly optimited, is very good mantainable and cant be writtin without native code.


This really depends on how well gwt compiles code and optimize code. But most of them time javascript functions can be written as gwt functions. Not sure which will be faster, hand optimized code or gwt optimized code.

sven
6 Aug 2009, 9:05 AM
At some point you have to do native methods. There is no way around this.

zgrossbart
6 Aug 2009, 10:07 AM
Hello,


My name is Zack and I wrote the blog post mentioned by fother at the start of this thread. The anti-pattern I mentioned in my article was using GWT to generate JavaScript code into element attributes like onclick and onmouseover. That is a pattern which is very difficult to maintain and unnecessary in GWT.


Writing GWT native methods is something I do frequently in my own projects. I mostly use to technique to call existing JavaScript libraries. Bridging code like this is what JSNI was made for.


I hope this helps.


Cheers,

Zack

TheBuzzer
6 Aug 2009, 12:46 PM
ya at some point it would be calling native java.

Most likely a libraries like gxt will because it is making a framework and might waste more time if referencing to all the gwt calls.

It is possible I think to make anything on top of the gwt framework without native code however you might be making too many objects wrap around each other and not have a clean javascript code anymore.

I still think some parts of the gxt does not seem that great because using firebug I see lot of div elements on top of each other to make a widget.

sven
6 Aug 2009, 1:00 PM
GXT is highly customizable. The layout is there for a reason.