On 23 fév, 16:36, Ian Petersen <[email protected]> wrote:
> GWT.create() is obviously not what you think it is.
GWT.create is probably not what you think it is.
GWT.create(MyClass.class) is *identical* to new MyClass(), except that
you can define rules so that it becomes new MySubClass() at compile-
time depending on the permutation being processed.
You can see MyClass o = GWT.create(MyClass.class) as the *exact*
equivalent of the following, where the condition is not expressible in
code (GWT doesn't provide a getCurrentUserAgent() for instance), has a
fixed value for a given permutation and is therefore optimized by the
compiler:
MyClass o;
if (<some condition is true>) {
o = new MySubClass();
} else {
o = new MyClass();
}
What's important here is that the "else" clause is *always* there, so
if there isn't any deferred binding rule, MyClass o = GWT.create
(MyClass.class) is *identical* to MyClass o = new MyClass().
It means that if MyClass is not a concrete class (abstract class or
interface) and/or has no zero-arg constructor, the compiler will fail,
as it would have if you had written new MyClass().
> As far as I know, you can't create any widgets with GWT.create().
Any widget (any class) with a zero-arg constructor can be instantiated
with GWT.create(), though I wouldn't recommend doing it (see my advice
to Eugen).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---