On Thursday, January 19, 2012 11:11:14 AM UTC+1, Raivis Vasilevskis wrote:
>
> First of all, thank you for the answer
>
> > // This still has to be written, to semantically determine what type of
> > widget you are planning to use in your editor
> >
> > interface CustomerView implements XXMarkerInterface {
> > TextBox field1;
> > Label field2; ...
> > ...
> > <SomeWidgetType> field10;
> >
> > }
>
> If I understand you right, this par still has to be written for every
> view I will create. I have literally hundreds if not thousands of
> them. All the data models are generated, so I don't have to worry
> about them. I want to write a generator, that would generate editors
> fields according to given data model in runtime.
Unless you generate some kind of "schema" and then dynamically build your
UI from that schema, it'll never be "at runtime" (and as you said, the
Editor framework also works at compile-time, just like almost everything in
GWT)
> If I still have to
> write those interfaces manually, that does not differ from writing
> editor classes manually. That's still the boilerplate hardcoding.
> Correct me if I didn't understand you correct.
Let's simplify things:
interface /* or class, it doesn't really matter */ Customer extends
XXXMarkerInterface<Customer> {
}
Now you have a "link" from CustomerView to Customer (by mean of the generic
type argument), that you can inspect at compile-time to generate the
concrete implementation for CustomerView (something like "hey, Customer as
a property "name" of type String, let's create a TextBox for it; and let's
use a DateBox for the "birthDate" property; and finally, generate the
EditorDriver interface and the code that GWT.create()s it")
That'd work, but everything would be automated when you "GWT Compile" your
app.
If I were you, I'd rather write a generator outside GWT; one that loads the
model classes (compiled, from the classpath, it's the easiest way) and
generate Java code out of it (same as above), and then use that generated
code from your GWT project. Difference: you can tweak the generated code
before "GWT Compiling" your app.
Simply use Java reflection to inspect your model classes, and FileWriter-s
to generate your code.
We use this approach to generate our RequestFactory proxies out of our
model classes; works very-well.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/0EwXuNT9XkEJ.
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.