Biggest GWT Pitfalls? [closed]

2019-01-12 13:06发布

I'm at the beginning/middle of a project that we chose to implement using GWT. Has anyone encountered any major pitfalls in using GWT (and GWT-EXT) that were unable to be overcome? How about from a performance perspective?

A couple things that we've seen/heard already include:

  • Google not being able to index content
  • CSS and styling in general seems to be a bit flaky

Looking for any additional feedback on these items as well. Thanks!

24条回答
Melony?
2楼-- · 2019-01-12 13:46

I'll add some points to the ones already mentioned:

  • Databinding/validation. GWT doesn't have a databinding/validation support out of the box, although there are some projects on this area starting to emerge. You'll find yourself writing alot of this:
TextField fname, faddress;
...
fname.setText(person.getName());
faddress.setText(person.getAddress());
...
  • Lazy loading. Since gwt is on the client side, lazy loading is really not an option. You'll have to design your RPCs and Domain Objects carefully in order to
    • send all your object data that is needed
    • avoid eager fetching all of your data
    • You'll have also to make sure that you will not send proxies/non serializable objects. hibernate4gwt can help you with these points.
  • UI design. It is harder to visualize an UI in java (Panels, Buttons, etc) than in html.
  • History support. GWT does not ship with a History subsystem, nor does it ship with any subsystem for nice urls or statefull bookmarking. You'll have to roll your own (although it has support for History tokens, which is a start). This happens with all AJAX toolkits AFAIK.

IMHO, GWT is missing a framework that has out of the box support for all of the issues mentioned on this 'thread'.

查看更多
劫难
3楼-- · 2019-01-12 13:49

I'll start by saying that I'm a massive GWT fan, but yes there are many pitfalls, but most if not all we were able to overcome:

Problem: Long compile times, as your project grows so does the amount of time it takes to compile it. I've heard of reports of 20 minute compiles, but mine are on average about 1 minute.

Solution: Split your code into separate modules, and tell ant to only build it when it's changed. Also while developing, you can massively speed up compile times by only building for one browser. You can do this by putting this into your .gwt.xml file:

<set-property name="user.agent" value="gecko1_8" />

Where gecko1_8 is Firefox 2+, ie6 is IE, etc.


Problem: Hosted mode is very slow (on OS X at least) and does not come close to matching the 'live' changes you get when you edit things like JSPs or Rails pages and hit refresh in your browser.

Solution: You can give the hosted mode more memory (I generally got for 512M) but it's still slow, I've found once you get good enough with GWT you stop using this. You make a large chunk of changes, then compile for just one browser (generally 20s worth of compile) and then just hit refresh in your browser.

Update: With GWT 2.0+ this is no longer an issue, because you use the new 'Development Mode'. It basically means you can run code directly in your browser of choice, so no loss of speed, plus you can firebug/inspect it, etc.

http://code.google.com/p/google-web-toolkit/wiki/UsingOOPHM


Problem: GWT code is java, and has a different mentality to laying out a HTML page, which makes taking a HTML design and turning it into GWT harder

Solution: Again you get used to this, but unfortunately converting a HTML design to a GWT design is always going to be slower than doing something like converting a HTML design to a JSP page.


Problem: GWT takes a bit of getting your head around, and is not yet mainstream. Meaning that most developers that join your team or maintain your code will have to learn it from scratch

Solution: It remains to be seen if GWT will take off, but if you're a company in control of who you hire, then you can always choose people that either know GWT or want to learn it.


Problem: GWT is a sledgehammer compared to something like jquery or just plain javascript. It takes a lot more setup to get it happening than just including a JS file.

Solution: Use libraries like jquery for smaller, simple tasks that are suited to those. Use GWT when you want to build something truly complex in AJAX, or where you need to pass your data back and forth via the RPC mechanism.


Problem: Sometimes in order to populate your GWT page, you need to make a server call when the page first loads. It can be annoying for the user to sit there and watch a loading symbol while you fetch the data you need.

Solution: In the case of a JSP page, your page was already rendered by the server before becoming HTML, so you can actually make all your GWT calls then, and pre-load them onto the page, for an instant load. See here for details:

Speed up Page Loading by pre-serializing your GWT calls


I've never had any problems CSS styling my widgets, out of the box, custom or otherwise, so I don't know what you mean by that being a pitfall?

As for performance, I've always found that once compiled GWT code is fast, and AJAX calls are nearly always smaller than doing a whole page refresh, but that's not really unique to GWT, though the native RPC packets that you get if you use a JAVA back end are pretty compact.

查看更多
迷人小祖宗
4楼-- · 2019-01-12 13:49

Slightly off-topic, but the #gwt channel on irc is very helpful, in-case you have a persistent problem.

查看更多
对你真心纯属浪费
5楼-- · 2019-01-12 13:50

Regarding GWT 2.4, Use Firefox when debugging GWT, it alot more faster then using chrome. And if you'll using only firefox, consider putting this line in your project.gwt.xml file

<set-property name="user.agent" value="gecko1_8" />

Also, If you're using eclipse, then add the following under arguments -> VM arguments:

-Xmx512m -XX:MaxPermSize=1024m -XX:PermSize=1024m

You can divide your server and client, and use the following under arguments -> Program arguments: -codeServerPort 9997 -startupUrl http://yourserver/project -noserver

Also, to prevent refreshing your server on each change, use JRebel http://zeroturnaround.com/blog/how-to-rock-out-with-jrebel-and-google-web-toolkit-gwt/ And here's a live demo http://www.youtube.com/watch?feature=player_embedded&v=4JGGFCzspaY

查看更多
Emotional °昔
6楼-- · 2019-01-12 13:51
  • The Async interface you have to write for each service interface looks like something that could have been automatically generated by the GWT compiler.
  • Compile times become long for large projects

But for a large Javascript project it's the best choice

查看更多
萌系小妹纸
7楼-- · 2019-01-12 13:51

I have done a lot of work on GWT recently, and this is wht i have to say:

  1. CSS styling is tricky only sometimes, use IE developer tool in IE and firebug in Firefox to figure out what exactly is happening and you will get a clear idea of what css needs to be changed
  2. You can use tricks to get google to index it. A very famous site is http://examples.roughian.com/ check its ratings at google. A far less famous site is www.salvin.in (couldnt resist to mention that), i optimised it to words: salvin home page (search google for these three words)

I do not know much about GWT-EXT, But i too am of the belief that there is no need to include Third party libraries.

Best of luck on your decision :)

查看更多
登录 后发表回答