DonX
DonX

Reputation: 16379

What is the use GWT generator?

I have seen that GWT framework is having generator feature. In what case we have to use gwt generator option and why it is needed? Can anyone tell me simply why,what is gwt generator? Done some googling. But not much helpful stuffs...

Upvotes: 20

Views: 9037

Answers (6)

Sam
Sam

Reputation: 2747

Check out this implementation: http://samuelschmid.blogspot.com/2012/05/using-generator-for-generic-class.html

You can create new Instances of classes on client with foo.newInstance("fully.qualified.class.name");

Upvotes: 0

user398051
user398051

Reputation: 141

I've done GWT development for 3 years now and I've written one generator :) I've written a couple of linkers for experimental purposes so I think they are more common, though still rare. The classic case is where you want to write

X x = GWT.create(X.class)

and have the particular subclass or implementation of X constructed at compile time based on, perhaps, annotations in the provided X class or interface. GWT uses them for things like the CSSResource.

Search for "GWT Generator Experiments" site:development.lombardi.com on google for some info about what I did.

Upvotes: 7

Joao Pereira
Joao Pereira

Reputation: 2534

I've started using GWT Generators where I needed Java Reflection. I've documented One of the use cases for using GWT generators here:

http://jpereira.eu/2011/01/30/wheres-my-java-reflection/

Hope it helps.

Upvotes: 2

Marius
Marius

Reputation: 1769

If you refer to code generator, yes, there will a tool supporting GWT 2.1 code generation. For more details and a quick start, see http://www.springsource.org/roo/start A general roo intro is here http://blog.springsource.com/2009/05/01/roo-part-1/

Another visual tutorial is at http://www.thescreencast.com/2010/05/how-to-gwt-roo.html

Upvotes: 0

Ashwin Prabhu
Ashwin Prabhu

Reputation: 7634

One of the use cases is to mimic reflection on the client side by building a factory class on the fly. I remember answering a question posted by you earlier on how to do this

How to create new instance from class name in gwt?

So i guess you already know the application. What else are you looking for? Can you be precise?

Upvotes: 1

Jason Hall
Jason Hall

Reputation: 20920

From this tutorial:

Generators allow the GWT coder to generate Java code at compile time and have it then be compiled along with the rest of the project into JavaScript.

This tutorial uses the example of generating a Map of values at compile time based on a properties file.

Upvotes: 16

Related Questions