Speaking of bindgen... :-)
bindgen makes dealing with tables very nice, as it's bindings can be
stateless, meaning you instantiate/declare them once, and then reuse
the binding to get values out of multiple instances.
For example:
EmployeeBinding b = new EmployeeBinding();
CellTable<Employee> t = new CellTable<Employee>();
t.addColumn(BoundColumn.ofString(b.name());
t.addColumn(BoundColumn.ofString(b.address());
t.setData(employees); // I forget exactly what this API call is
When rendering, column1 can use the single binding it was passed to
it to ask "what is this employee's name", then ask "what is the
next employee's name", etc., based on what employee CellTable
hands to it.
Here is the BoundColumn class:
But the usage example above is really ugly. It needs a pectin quality
DSL. :-)
I haven't used CellTable a lot (yet) either, so this is just a
prototype. It needs a lot of work.
Tangentially, I really wish bindgen wasn't needed, that what it
accomplishes was baked into the language. Closures are close, e.g.:
t.addColumn(BoundColumn.ofString(|e| => e.name))
But doing read/write with closures requires repetition, e.g.:
form.addField(|e| => e.name, |e,newValue| => e.name = newValue)
Which is how Lift does things, AFAIK. It works, but is a lot of extra
typing when just "e.name" should do.
- Stephen
Shouldn't it be easy to hook up the validation in the ValueUpdater, or
is that too late?
I've spent some time today playing with CellTable, and here's my primary
thought wrt using CellTable with pectin-style rich models.
CellTable's differentiating feature is that it flyweight-based Cells
can scale to 1000s of rows.
However:
1. If you have 1000s of rows, will the browser handle 1000s of rows X Ns
of columns pectin model objects taking up memory, doing the various
smart/reactive things they do?
2. If you don't have 1000s of rows, say <100, why bother with
CellTable's different/flyweight-based API? Use regular, pectin
-loving widgets, in a style somewhat like:
http://www.draconianoverlord.com/2010/03/31/gwt-mvp-tables.html
(Ugh, I really need to update that.)
So...I dunno, what do you guys' think about having "more than a few"
rich model objects floating around?
Maybe I'm being too pessimistic; given they're pure JavaScript objects,
and not all hooking up events (somehow leveraging the CellTable's event
dispatching), maybe it would be fine?
Either way, I'd love to see a heavy dose of pectin DSL awesomeness
applied to the CellTable API. :-)
- Stephen
CellTable's differentiating feature is that it flyweight-based Cells
can scale to 1000s of rows.
However:
1. If you have 1000s of rows, will the browser handle 1000s of rows X Ns
of columns pectin model objects taking up memory, doing the various
smart/reactive things they do?
2. If you don't have 1000s of rows, say <100, why bother with
CellTable's different/flyweight-based API? Use regular, pectin
-loving widgets, in a style somewhat like:
http://www.draconianoverlord.com/2010/03/31/gwt-mvp-tables.html
(Ugh, I really need to update that.)
So...I dunno, what do you guys' think about having "more than a few"
rich model objects floating around?
Either way, I'd love to see a heavy dose of pectin DSL awesomeness
applied to the CellTable API. :-)