> Can you provide more information on the generator side and how can i > accomplish this ?
It's not really well documented as far as I know, so the best place to get information is by reading the source code of GWT and other libraries that implement generators. The basic idea is that in your .gwt.xml file you specify an interface and a Generator<http://code.google.com/p/google-web-toolkit/source/browse/trunk/dev/core/src/com/google/gwt/core/ext/Generator.java>class. When the GWT compiler comes across a GWT.create(Foo.class) call where Foo.class extends the interface you specified, it calls your Generator class to create the implementation of that interface. Your Generator class can then generate the Java code for the implementation of the interface, and an instance of that generated class will be returned by the GWT.create() call. This is how GWT's RPC interfaces work (see RemoteService.gwt.xml<http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/RemoteService.gwt.xml> and ServiceInterfaceProxyGenerator<http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceProxyGenerator.java>) as well as many other GWT features (localization, UI binder, client bundles). You can also define a class that gets invoked at the GWT compiler's link phase, but I don't think you'd need to do this just for JSON marshaling. Jamie On Sat, Dec 5, 2009 at 7:10 AM, keyboard_samurai <[email protected]> wrote: > Thanks for the reply ... > > Can you provide more information on the generator side and how can i > accomplish this ? > > I would definitely look into the lovely json rpc code. Any directions > on this would be greatly appreciated. > > Thank you ! > > Cheers! > > On Dec 4, 9:43 pm, Jamie Gennis <[email protected]> wrote: > > Annotations in client code can be used during GWT's rebind phase of the > > compilation, but they are not accessible at runtime on the client side. > GWT > > doesn't support much of Java's reflection functionality on the client > side > > in order to keep the compiled Javascript code smaller. > > > > You can write a custom generator, which can be called to create > > implementation code for specific interfaces during the rebind phase, to > > generate your marshaling code at compile-time. This is the approach > taken > > by lovely-gwt-jsonrpc <http://code.google.com/p/lovely-gwt-jsonrpc/>, > for > > example, and is how all of GWT's built-in RPC functionality works. You > may > > be able to leverage some or all of the work in that project to accomplish > > what you're trying to do. > > > > Jamie > > > > > > > > On Thu, Dec 3, 2009 at 7:21 PM, keyboard_samurai <[email protected]> > wrote: > > > Hi, > > > > > I am a newbie to GWT. Need to know if GWT can support custom > > > annotations on client side ?. The reason for custom annotations is i > > > would be communicating with the backend service through json and not > > > gwt rpc and i wouldnt like each developer to write the same piece of > > > code. So i was planning to annotated my entity classes which can be > > > used for marshalling and unmarshalling json response. > > > > > Please do let me know if this can be done in GWT. > > > > > Thanks in advance > > > > > cheers! > > > > > -- > > > > > You received this message because you are subscribed to the Google > Groups > > > "Google Web Toolkit" group. > > > To post to this group, send email to > [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<google-web-toolkit%[email protected]><google-web-toolkit%2Bunsubs > [email protected]> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/google-web-toolkit?hl=en. > > -- > > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-web-toolkit%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
