I wouldn't be surprised if this post maybe would have made more sense on the GWT forums, but I'm still trying to tease apart in my mind what aspect of my obstacle here might be the design pattern used by Scaffolding, or else whether this is just a core GWT concern.
My very brief question is: how can I get RequestFactoryEditorDriver working with a ListEditor that instantiates subeditors that directly edit the properties of the contained objects. The dynatablerf code sample referenced in
http://code.google.com/webtoolkit/doc/latest/DevGuideUiEditors.html#Provided_Adapters only seems to manipulate the child collections, but not change values on the contained objects. And my Google searches for people dealing with this have not proven fruitful yet.
Now on to the much more verbose version of this question...
Here is how I set up my test case in ME4S (I've attached the project as described below). I selected defaults for everything I don't specify below:
1. I have latest Google Plugin for Eclipse installed that has GWT 2.4
2. Created a Web Project Named "NestedEditingInGWTScaffolding" and selected Java EE 6.0
3. Edit the Google Web Toolkit settings to use GWT default version of 2.4 and set Web Application that it has a WAR file and to launch and deploy from that directory
4. Configured the Java Compiler Annotation Processing (per other forum posts) to get around the "validator issue"
5. Ran through the "Scaffolding Sprint CRUD Wizard" accepting all the defaults other than
a. Selected a Database Schema as the source
b. Used the CLASSICCARS sample Derby DB and included just the Customer and Payment tables to keep it simple
c. Opted to treat both of them as parent objects (but this will be the topic of this post)
d. My root namespace was com.nevo (but that doesn't really matter)
e. Opted for the GWT front end (obviously this is also key to this posting)
f. Accepted all the remaining defaults
6. Configured a Web Development debug configuration for the project to not use the internal server so I can make sure to spin up Tomcat separately to avoid other issues (see
http://www.myeclipseide.com/index.php?name=PNphpBB2&file=viewtopic&p=128357#128357)
Then I made a minor tweak to the generated application to try to be able to edit data about a Payment within the edit/save context of the customer. I understand this was supposedly explicitly not supported by the Scaffold application, but I'm trying to understand why it can't be easily morphed into that.
I edited the PaymentSetEditor.java file to include a DoubleBox object named amountEditor in the inner class NameLabel and I added it to the HorizontalPanel. This was 1 line of code change as follows:
class NameLabel extends Composite implements ValueAwareEditor<PaymentProxy> {
final DoubleBox amountEditor = new DoubleBox();
...
public NameLabel(final EventBus eventBus) {
...
hp.add(checknumberEditor);
hp.add(amountEditor); // new line
initWidget(hp);
This succeeds in renders the amount in an editable form when the customer is under edit, but changes to the value don't seem to get moved back into the corresponding proxy object as I would have expected when the RequestFactoryEditorDriver.flush() is invoked.
I'm struggling to figure out if one of the following two points explains this, whether there is some other problem, or whether I am actually heading down a dead-end which I would find hard to believe:
1. The PaymentSetEditor class declares itself with the interface "LeafValueEditor" which basically tells the GWT Editor framework to not descend into that type, and that explicit setValue and getValue methods will be written. I've been exploring removing that interface, but I'm still trying to understand the implications of that. After tell the Editor to then ignore some properties it would otherwise try to "bind" with the Editor framework (which made sense to set the Editor.Ignore annotation on), it runs, but doesn't seem to "fix" the problem and actually instead seems to make it so that the add/remove from the collection no longer propagates to the server. I'm guessing because The LeafValueEditor is the only interface where the getValue() method will be called to return the revised collection.
2. (regarding this next point, it might have an interplay with #1, but I'm not sure) It seems that GWT 2.3 had a bug where the RequestFactoryEditorDriver doesn't correctly propagate the RequestContext to subeditors within a ListEditor. They claim to have gotten the fix into GWT 2.4 which I am running. I even confirmed that against the GWT svn repository, and double checked against the source code included in the GWT 2.4 plugin installed by the Google Plugin for Eclipse. So, that research path hasn't clarified things, but it seemed very relevant. Here is the GWT issue tracking that:
http://code.google.com/p/google-web-toolkit/issues/detail?id=6081
Regarding #2, I enhanced the two class definitions to contain the HasRequestContext interface
public class PaymentSetEditor extends Composite implements
ValueAwareEditor<Set<PaymentProxy>>, LeafValueEditor<Set<PaymentProxy>>,
HasRequestContext<Set<PaymentProxy>> { // new interface
class NameLabel extends Composite implements ValueAwareEditor<PaymentProxy>,
HasRequestContext<PaymentProxy> { // new interface
and implemented the necessary interface method, and I clearly see a "valid" RequestContext set on the PaymentSetEditor, but a NULL RequestContext is being set into the NameLabels generated by the ListEditor. This seems to be exactly what was suggested in that GWT issue, and even after I worked through removing LeafValueEditor (as described in #1 above), I still saw NULL RequestContexts set on the ListEditor's NameLabel editors.
I attached my workspace, but had to delete the following files to keep the attachment size down:
* NestedEditingInGWTScaffolding-Compacted\gwt-unitCache
* NestedEditingInGWTScaffolding-Compacted\WebRoot\WEB-INF\lib\gwt-servlet.jar
I also included a breakpoint export to flag the key points.
Any help would be appreciated. And please let me know if this is the wrong place to be posting this. I imagine I will likely start trying to build a bottom-up reproducible case next without Scaffolding in the picture.
Pete