We're about halfway through our first GWT project and we've written a
small library to solve this problem because our application has user
definable data fields.
We've create Widgets that include some type of input field (all the
usual html form suspects) that's also bound to a label. The widget
also contains a reference to the DTO field that is updated when the
input field is modified (happens automatically with an onChange
event). Validation takes place when the field is changed using a
regular expression and an error message is displayed if no match is
found.
This nice thing about this is that all we now do is throw a DTO model
at our library, the DTO model includes the data and also meta data. A
routine in the library uses the meta data to create widgets and
display them, referencing each DTO field as appropriate. The DTO is
updated automatically, there's no marshalling / un-marshalling of data
to do. For the developer, the DTO objects are fetched using RPC,
passed to the model, the user clicks on save and nothing happens other
than just passing the DTO to the RPC update method.
It's by no-means perfect, it's a bit of fudge for static fields that
don't have meta data (but it still works) and it's saved us lots of
time and effort. Coupled with a framework we've developed to copy
persistent object graphs to DTOs automatically (and back again), it
makes the whole process saving data on the server with hibernate a
very short coding exercise!
We are planning to open source these libraries but don't expect it
anytime soon as it's still fairly tangled up in a customer's
application and we need to get that finished before Christmas, then we
can untangle it into a generic library in January. We're only a small
company and we just don't have the time to do it earlier. If lots of
people show an interest, then we'll upload it as it is into googles
forge and let others make it pretty :)
Kind Regards,
Chris.
ps. The object copying bit will need a rework once GWT1.5 is released
due to the annotations support, I had to jump through hoops to get
annotations to work on the server side but avoid them on the client
objects!
On Nov 23, 5:37 pm, Rebornspirit <
maarten.vold...@gmail.com> wrote:
> I think one of the biggest missing features is that there is no out-of-
> the-box solution for form databinding / validation. So I was wondering
> what all of you out there are using? Because I guess we are all
> dealing with somewhat of the same issue, so perhaps we are dealing it
> the same way or aren't we .... scary ;-)
>
[snip]