GWT doesn't support (and from what I've heard, never will) support true reflection. It introduces too many problems.
On Tue, Apr 7, 2009 at 4:21 AM, KevinM <[email protected]> wrote: > > Hi, > > I'm working on a generator of GWT Java source code from XML files > based on JAXX (a generator of Swing source code from XML) and I've got > a problem : when I parse the XML file, I get the java classes of the > tags using Class.forName(className) during runtime. It's working well > for usual classes but not for GWT client classes, because Class.forName > (className) runs GWT.create and GWT doesn't permit to do it during > runtime. In fact, it is not working - you are probably running hosted mode which runs your code in a JVM. When you actually compile your code, you'll find it doesn't work. Obviously you can't instantiate the GWT GUI classes because they contain native Javascript. > > > So I find a way to get a Class object corresponding to the class of my > tag (e.g. Button) without instantiate a Button object (only a Class > object)... At that point, you have to do a manual lookup - if (Button.class.getName().equals(myTagName) ) return new Button(); if (OtherWidget.class.getName().equals(myTagName)) return new OtherWidget(); > > > I'm not trying to generate javascript but java code, so I can't use > Generators... I've been stuck on this for days and I don't find any > solution... Does anyone have any idea ? What do you mean you are trying to generate Java code? GWT doesn't actually have Java in it - it does support a debug mode where it emulates the javascript by running your code in a JVM, but the behaviour is slightly different. > > Thanks > > Kevin > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
