On Sat, Dec 12, 2009 at 2:06 PM, philippe <[email protected]> wrote:
> Using annotations to define the presentation is a bad practice, as
> being able to define the size of components in Java. The best way to
> separate the presentation logic is to give a class name to an element
> and define its presentation in a separate CSS file. See csszengarden
> as reference.
In my case, annotations describe presentation. The downside of this
is that presentation options have to be well defined beforehand and
implemented somehow, with UIBinder for instance.
One case of where the annotations approach that I've taken does well
IMO, is in describing forms. Designing a GWT feature or function
within an application that captures user input, often starts by
defining an object to be used for RPC. So for instance, I have a
registration form that will pass instances of the following class.
class Registration {
String firstname;
String lastname;
String email;
String username;
String password;
...
}
Let's say that I know I'm storing these in a database so I write all
the persistence code and unit tests and all of that works great. Now,
I want the actual form. The approach I've taken is to say, I already
have a portion of the info I need to describe this form, the model,
but I need to add a few hints, this is the approach, I believe, that
Rails and Django take with their models, and results in a very fast
turnaround time for something like an app administration. So here are
the changes I need to make in order to get a form rendered.
@Form(..)
class Registration {
@CharField(..)
String firstname
@CharField(..)
String lastname;
@EmailField(..)
String email;
@CharField(..)
String username;
@PasswordField(..)
String password;
..
}
And with a few more lines of client-side GWT code, I have a form
rendered with data-binding. The data-binding portion means that as a
user enters values into the form, a Registration object in the
background is upgraded with those values.
You can see this working in the demo here:
http://gxtforms.appspot.com/#simpleform
This is just another approach which is similar to other approaches
(django and Rails admin and templating), that I feel adds some value
to GWT. It does not replace something like UIBinder for complex
layouts.
-Dave
--
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.