RequestFactory, Editor Framework, and CellTable

522 megtekintés
Ugrás az első olvasatlan üzenetre

Jake Wharton

olvasatlan,
2011. febr. 28. 20:18:352011. 02. 28.
– google-we...@googlegroups.com
I am looking to determine a method for integrating the editing abilities of the CellTable, automatic binding of the Editor framework, and the client-server communication of the RequestFactory together.

Given two classes, Parent and Child, I am attempting to create a ParentEditor which includes a listing of each associated Child. Without going to a separate editor, I would like to be able to add and remove children as well as modify properties of each child.

It seems obvious as to how to integrate a List<Child> instance with the CellTable, how to use ListEditor to bind a list of objects to individual sub-editors, and how to add, remove, and update a Child through the RequestFactory. What is not obvious is how to properly hook all three together so that they work in harmony.

If anyone has code, suggestions, or links that can assist in this use case, or perhaps even a table-based editing implementation using only Editors and the RequestFactory it would be much appreciated.

Thomas Broyer

olvasatlan,
2011. márc. 1. 9:42:592011. 03. 01.
– google-we...@googlegroups.com
I don't think CellTable's editing abilities are meant to be used with the Editor framework. The Editor framework is based on a Flow Synchronization pattern while CellTable generally directly edits its value. To be able to edit objects in a CellTable "bound" through the Editor framework, you'd have to provide your own EditorSource to a ListEditor (i.e. do not use HasDataEditor, but rather somehow duplicate it) with subeditors for the fields you'll edit (you can use SimpleEditors), and have your CellTable extract its data from those subeditors, and push updates into them too. This would be so that the actual object being edited is only modified when you later flush() your EditorDriver.
This is only in theory though, I haven't tried it.

Note that adding and removing items from the list is a different story, as the list you get from the ListEditor/HasDataEditor is already a "working copy" of the one passed to the editor.
This I experimented with, in two fashions depending on the constraints:
  • simply modify the list, as it would be persisted with the whole object being edited (or with a service call passing the edited list as an argument);
  • queue add and remove service calls to our RequestContext, that we'll fire later on (after we flush the EditorDriver to persist changes made in other non-list editors)
Because we do not edit the list items' properties, we were able to use the HasDataEditor (with a CellList in our case, but you could use a CellTable equally well)

Colin Alworth

olvasatlan,
2011. márc. 3. 15:03:112011. 03. 03.
– google-we...@googlegroups.com
I wonder if you can elaborate a bit more on some of your points, or maybe point out where the flaw in my thinking is. I think that a HasDataEditor could be used correctly to achieve this, except for two points: HasDataEditor doesn't hold changes and flush them out when asked to, and bug 5981 (which I've posted a possible fix for, but seems to not have gotten any attention).

A HasDataEditor subclass with a set of changes to make could deal with this - those changes could be queued up as in the CwCellSampler, and flushed when the HasDataEditor gets a call to flush(). As time permits I've been working on a tool to help with CellTable setup, mostly building of columns, and this could easily be extended to queue up changes for the editor. I've begun work on such a feature, but your suggestion that these may be incompatible gives me pause.

Issue 5981 seems to be a simple typo preventing entityproxies from being correctly passed into LeafValueEditors (and possibly ValueAwareEditors). With that cleared up and a clean way to queue up list changes, I think binding a CellTable should become quite straightforward.

Thomas Broyer

olvasatlan,
2011. márc. 4. 6:10:122011. 03. 04.
– google-we...@googlegroups.com


On Thursday, March 3, 2011 9:03:11 PM UTC+1, Colin Alworth wrote:
I wonder if you can elaborate a bit more on some of your points, or maybe point out where the flaw in my thinking is. I think that a HasDataEditor could be used correctly to achieve this, except for two points: HasDataEditor doesn't hold changes and flush them out when asked to, and bug 5981 (which I've posted a possible fix for, but seems to not have gotten any attention).

A HasDataEditor subclass with a set of changes to make could deal with this - those changes could be queued up as in the CwCellSampler, and flushed when the HasDataEditor gets a call to flush(). As time permits I've been working on a tool to help with CellTable setup, mostly building of columns, and this could easily be extended to queue up changes for the editor. I've begun work on such a feature, but your suggestion that these may be incompatible gives me pause.

I think it's workable (and a good idea!). You'd still have to enqueue changes to the HasDataEditor (or its IndexedEditor) from your FieldUpdaters though, which is a bit of boilerplate code, but I can't think of a more "integrated" way (unless you add a generator somewhere to generate those specialized PendingChange and FieldUpdater subclasses).

Colin Alworth

olvasatlan,
2011. márc. 4. 12:54:302011. 03. 04.
– google-we...@googlegroups.com
I've already got a generator that builds FieldUpdater instances (as well as Column instances, complete with getValue calls), so it is just a matter of extending it a little further to make this PendingChange-like thing.

And, of course, to either stop HasDataEditor from implementing LeafValueEditor, or patch my own copy of GWT. Patching isn't ideal, as it would prevent others from using this library I'm trying to make, but it would be a decent stopgap measure.

Any suggestions on how to squeak a little louder to get that bug greased? Or can a Googler comment on the status of the issue?

Aldo Neto

olvasatlan,
2011. márc. 18. 13:42:552011. 03. 18.
– google-we...@googlegroups.com
Hi,

Thanks for your contribution. I checked your code and it seems to help me with my problem. However, I'm still not able to use the HasDataFlushableEditor class with my "Editor". It only works when I change it to a LeafValueEditor (just like the HasDataEditor). 

My question is: what do I have to do in order to use the HasDataFlushableEditor class? What I see in my code is that the table is created but no data is added, i mean, no row is created. Do you have any clue?

Thanks,
Aldo


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Colin Alworth

olvasatlan,
2011. márc. 18. 14:09:392011. 03. 18.
– google-we...@googlegroups.com, Aldo Neto
It is a work in progress – unfortunately, I ran out of time after putting it in, and was unable to verify that it does what I need it to do. I hope to spend time on it this weekend, and be able to report back that it works as it should. For now, use the configure(CellTable) overload only, and stick with a regular, broken, HasDataEditor+AbstractEditorDelegate, without edits.

Sorry for the confusion, and thank you for your interest.
-Colin
--
218.248.6165
nilo...@gmail.com
Válasz mindenkinek
Válasz a szerzőnek
Továbbítás
0 új üzenet