RequestFactoryEditorDriver example?

1,949 views
Skip to first unread message

George Moschovitis

unread,
Jan 30, 2011, 2:18:52 PM1/30/11
to google-we...@googlegroups.com
Is there an example (w/ sample code) demonstrating how to use RequestFactoryEditorDriver?
Something similar to this (https://gist.github.com/780560) would be great!

thanks in advance,
-g.

Thomas Broyer

unread,
Jan 30, 2011, 5:27:18 PM1/30/11
to google-we...@googlegroups.com
The DynaTableRf sample from the GWT SDK uses RequestFactoryEditorDriver, but it really isn't that different from the SimpleBeanEditorDriver (you just have to pass a RequestContext so that the driver can do an .edit() on each proxy found in the edited object graph; or use display() or pass a null RequestContext to display a proxy without edit()ing it; note that in that case flush() will throw though)

(glad that you liked my gist ;-) )

George Moschovitis

unread,
Jan 31, 2011, 6:27:06 AM1/31/11
to google-we...@googlegroups.com
I thought it would be something similar, but still I can't get this to work. For example flush() returns a requestContext() how can I save the edited object (by firing a method to the server side service). And btw how can I create an editor for a new object? should I pass null to initialize()?

really, a full, working example would be *very* useful for newbies like me.

thanks,
-g.

Bálint Kriván

unread,
Jan 31, 2011, 8:12:38 AM1/31/11
to google-we...@googlegroups.com
Hi George!

This is how I do this:

        RequestContext context = driver.flush();

        if (driver.hasErrors()) {
            for (EditorError ee : driver.getErrors()) {
                GWT.log(ee.getMessage());
            }
            return;
        }

        context.fire(new Receiver<Void>() {

            @Override
            public void onSuccess(Void response) {
            }
        });

You just simply call fire() method on the RequestContext.

And this is how I initialize the driver:

        driver.initialize(requestFactory, view.getEditor());
        MyRequest req = requestFactory.myRequest();
        req.persist().using(proxy);
        driver.edit(proxy, req);

Here you define, which operation should be invoked (persist in this particular case), when you call fire(). I hope this helps!
--
Üdv,
Kriván Bálint

Bálint Kriván

unread,
Jan 31, 2011, 8:13:32 AM1/31/11
to google-we...@googlegroups.com
(Sorry, the syntax highlighted stuff got screwed up, but I hope it's still readable)

--
Üdv,
Kriván Bálint

George Moschovitis

unread,
Jan 31, 2011, 1:00:41 PM1/31/11
to google-we...@googlegroups.com
Here you define, which operation should be invoked (persist in this particular case), when you call fire(). I hope this helps!

the initialization part was what I was missing, thanks!

-g. 

George Moschovitis

unread,
Jan 31, 2011, 1:14:17 PM1/31/11
to google-we...@googlegroups.com
One question,

how can I initialize the driver in a 'newObject' scenario, if I don't want to edit an existing object but create a new one instead.

-g.

George Moschovitis

unread,
Jan 31, 2011, 1:34:54 PM1/31/11
to google-we...@googlegroups.com
Another problem...

I tried your suggestion and it seems to work with one important problem:
the object/proxy returned is the original proxy passed to the editor and not the edited object...

any idea what might be wrong?

-g.

Bálint Kriván

unread,
Jan 31, 2011, 2:39:41 PM1/31/11
to google-we...@googlegroups.com
Well, I didn't try it myself, but I guess:

MyRequest req = requestFactory.myRequest();
MyProxy proxy = req.create(MyProxy.class);
req.persist().using(proxy);
driver.edit(proxy, req);
--
Üdv,
Kriván Bálint

Bálint Kriván

unread,
Jan 31, 2011, 2:42:08 PM1/31/11
to google-we...@googlegroups.com
Sorry, I don't get it clearly, which returned proxy? Where do you use a returned one? Using flush() you get the Context, not the Proxy object.


-g.

--
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.



--
Üdv,
Kriván Bálint

BB

unread,
Jan 31, 2011, 2:57:52 PM1/31/11
to google-we...@googlegroups.com
Thanks!
That is working for me! I was looking for it too.
I didn't called req.persist().using(proxy); on the newly created proxy.

George Moschovitis

unread,
Jan 31, 2011, 4:04:32 PM1/31/11
to google-we...@googlegroups.com
When I call fire(), the object passed to the server side method (public static void persist(MyObject obj) is the original (before editing) object.

-g.

Bálint Kriván

unread,
Feb 1, 2011, 6:24:00 AM2/1/11
to google-we...@googlegroups.com
Well, I believe the persist method shouldn't be static, it's an InstanceRequest:

public void persist() {
  // [this] is the MyObject instance, you should persist/merge this one
}

and this is the Request interface:

@Service(MyObject.class)
public interface ProgramRequest extends RequestContext {
  InstanceRequest<MyProxy, Void> persist();
}

I'm not sure, that it won't work (but now it seems it isn't working for you) with pure Request<> persist(MyProxy proxy); but then you can't use using(); stuff, and maybe the RequestContext won't save the stuff like this, because you don't use and InstanceRequest. It's worth a shot :)

Let me know if that was the problem.

Bálint Kriván

unread,
Feb 2, 2011, 7:26:56 AM2/2/11
to google-we...@googlegroups.com
Well, I've just introduced Locator and ServiceLocator stuff to my code, to be able to use EJB beans, and I replaced InstanceRequest to Request on persist() method. Because in EJB, you need the entity as argument, because "this" will be the bean instance not the entity of course. And it works perfectly, so the problem is elsewhere, so using this:

@Service(MyObject.class)
public interface ProgramRequest extends RequestContext {
  Request<Void> persist(MyProxy proxy);
}

and this:

req.persist(proxy);
driver.edit(proxy, req);

It works perfectly. So I'm not sure what is the issue with your code, can you show a snippet?

2011/2/1 Bálint Kriván <bal...@krivan.info>
--
Üdv,
Kriván Bálint

George Moschovitis

unread,
Feb 3, 2011, 2:03:46 PM2/3/11
to google-we...@googlegroups.com
OK, will give another try to identify the problem.

-g.

George Moschovitis

unread,
Feb 9, 2011, 4:36:53 AM2/9/11
to google-we...@googlegroups.com

It works perfectly. So I'm not sure what is the issue with your code, can you show a snippet?


OK, I still can't get this to work, here is a snippet:

 public class ArticleEditor extends Composite implements Editor<ArticleProxy> {
    interface Binder extends UiBinder<Widget, ArticleEditor> {
    }

    private static Binder uiBinder = GWT.create(Binder.class);

    @UiField
    TextBox title;
   
    @UiField
    DateBox created;

    public ArticleEditor() {
        initWidget(uiBinder.createAndBindUi(this));
    }
}

--

public class EditView extends Composite {
    interface Binder extends UiBinder<Widget, EditView> {
    }

    interface Driver extends RequestFactoryEditorDriver<ArticleProxy, ArticleEditor> {
    }

    private static Binder uiBinder = GWT.create(Binder.class);

    private Driver driver;
    private AppRequestFactory requestFactory;
    private ArticleRequestContext requestContext;
   
    @UiField
    ArticleEditor articleEditor;

    @UiField
    Button saveButton;
       
    public EditView(AppRequestFactory requestFactory) {
        initWidget(uiBinder.createAndBindUi(this));

        this.requestFactory = requestFactory;
        this.requestContext = requestFactory.getArticleRequestContext();
       
        saveButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {

                RequestContext context = driver.flush();

                if (driver.hasErrors()) {
                    Window.alert("Driver errors!");

                }

                context.fire(new Receiver<Void>() {
                    @Override
                    public void onSuccess(Void response) {
                        Window.alert("Success!");
                    }

                    @Override
                    public void onViolation(Set<Violation> errors) {
                        StringBuilder sb = new StringBuilder();
                        for (Violation e : errors) {
                            sb.append(e.getPath()).append(": ").
                                    append(e.getMessage());
                        }
                        Window.alert(sb.toString());
                    }
                });
            }
        });
    }

    public void edit() {
        // Edit a new article.
        edit(requestContext.create(ArticleProxy.class));
    }

    public void edit(ArticleProxy article) {
        driver = GWT.create(Driver.class);
        driver.initialize(requestFactory, articleEditor);
        requestContext.persist(article);
        driver.edit(article, requestContext);
    }
}

--

EditView view = new EditView(requestFactory);
view.edit(); // Edit new article
RootPanel.get().add(view);


The problem is that even though I fill the ArticleEditor form, I get a violation error that the title field is null!
It seems, after flush(), the driver still keeps the original, unedited object.

any ideas?

-g.

Vasily

unread,
Mar 5, 2011, 6:26:04 AM3/5/11
to Google Web Toolkit
I've tried that and got "Attempting to edit an EntityProxy previously
edited by another RequestContex"... :(

Could somebody help me understand what kind of driver should I use...
1. I have ContactProxy which have List<PhoneProxy>
2. User may add/edit/remove phones, so I wrote my own editor on the
base of ListEditor
3. As I understood, when user clicks on 'Add phone' btn, I have to:
- create an empty proxy;
- persist it;
- add to the listEditor;
4. Then user may edit it & click 'save' which gonna persist changes.

The questions is:
1. What kind of driver should I use... BeanDriver or FactoryDriver?
2. I Really don't like that approach when I have to persist an empty
proxy every time user want to add something... How to implement
approach when user may create any number of new phones & they will be
persisted upon 'save' clicked?

Thx!



On Jan 31, 10:39 pm, Bálint Kriván <bal...@krivan.info> wrote:
> Well, I didn't try it myself, but I guess:
>
> MyRequest req = requestFactory.myRequest();
> MyProxy proxy = req.create(MyProxy.class);
> req.persist().using(proxy);
> driver.edit(proxy, req);
>
> On Mon, Jan 31, 2011 at 7:14 PM, George Moschovitis <
>

Thomas Broyer

unread,
Mar 5, 2011, 8:56:07 AM3/5/11
to google-we...@googlegroups.com


On Saturday, March 5, 2011 12:26:04 PM UTC+1, Vasily wrote:
I've tried that and got "Attempting to edit an EntityProxy previously
edited by another RequestContex"... :(

Could somebody help me understand what kind of driver should I use...
1. I have ContactProxy which have List<PhoneProxy>
2. User may add/edit/remove phones, so I wrote my own editor on the
base of ListEditor
3. As I understood, when user clicks on 'Add phone' btn, I have to:
    - create an empty proxy;
    - persist it;
    - add to the listEditor;

The second step is not required; it entirely depends how persisting the ContactProxy works (whether it would persist a new Phone or the Phone has to be persisted on its own).
 
4. Then user may edit it & click 'save' which gonna persist changes.

The questions is:
1. What kind of driver should I use... BeanDriver or FactoryDriver?

The difference are:
  • RFED will context.edit() any proxy it sees (and the return type of flush()).
  • RFED has a getPaths() to help you make your "load" requests (context.loadObject(id).with(driver.getPaths()).fire(...))
  • RFED has a setViolations to display
But in 2.3 there will be changes: RFED introduce special support for a HasRequestContext interface, similar to HasEditorDelegate but giving your the RequestContext, so the editor can do a context.create() on the same context that is used to edit the proxies (probably the reason you have the "" exception): http://code.google.com/p/google-web-toolkit/issues/detail?id=5892

When Bean Validation will be supported in GWT, all editor drivers will have setConstraintViolations (and setViolations will be deprecated): http://code.google.com/p/google-web-toolkit/issues/detail?id=5567
 
2. I Really don't like that approach when I have to persist an empty
proxy every time user want to add something... How to implement
approach when user may create any number of new phones & they will be
persisted upon 'save' clicked?

Depending on your technical constraints (see above), you have 2 solutions:
  • enqueue a persist() call of the created proxy on the request context so that when you fire() it in response to the "save" button being clicked, you'll persist() all created proxies and the ContactProxy.
  • on the server-side, make sure the Phone instances from the Contact's phones list are correctly persisted: updated or created if needed.
But it all depends on how your server-side code works, and what it's able to do.

Vasily

unread,
Mar 5, 2011, 10:56:42 AM3/5/11
to Google Web Toolkit
> > 2. User may add/edit/remove phones, so I wrote my own editor...

> The second step is not required; it entirely depends how persisting the
> ContactProxy works (whether it would persist a new Phone or the Phone has to
> be persisted on its own).

C'est bon :) I want Phones to be persisted by edit activity for
ContactProxy... cause I'm trying to implement following use cases:
1. User edit fields of ContactProxy...
2. User edit list of PhoneProxy for current ContactProxy... It means
he's able to add/remove/edit phones...
3. User click 'Save' and all changes persisting in DB.
It means I want 'Save' to be like a transaction... I defenitely don't
want to persist phones on it's own.

Here is some code.

I have ContactProxy{
some_fields
List<PhoneProxy> phoneList;
}

Also have an edit activity & edit view for ContactProxy.

ContactView{
some_contact_proxy_fields
PhoneListEditor phoneListEditor;

Button saveBtn;
}

ListEditor seems to provide a good boilerplate code to manage UI of
list items, so, I've implemented PhoneListEditor on the base of
ListEditor.

PhoneListEditor implements ValueAwareEditor<List<PhoneNumProxy>>,
LeafValueEditor<List<PhoneNumProxy>>{
VerticalPanel container = new VerticalPanel();

public interface Driver extends
RequestFactoryEditorDriver<List<PhoneProxy>, ListEditor<PhoneProxy,
PhoneEditView>> {}

private ListEditor<PhoneProxy, PhoneEditView> listEditor;

private List<PhoneNumProxy> displayedList;

PhoneListEditor(){
initWidget(container);
listEditor= ListEditor.of(new PhoneEditorSource());

driver = GWT.<Driver> create(Driver.class);
driver.initialize(eventBus, factory, listEditor);
driver.display(new ArrayList<PhoneProxy>());

displayedList=listEditor.getList();
}

public void addClicked() {
PhoneRequest rq=factory.phoneRequest();
PhoneProxy proxy=rq.create(PhoneProxy.class);
rq.persist().using(proxy);
displayedList.add(proxy);
}

public List<PhoneNumProxy> getValue() {
return new ArrayList<PhoneProxy>(displayedList);
}

public void setValue(List<PhoneNumProxy> value) {
for (PhoneNumProxy itemValue : value) {
displayedList.add(itemValue);
}
}

public void flush() {
driver.flush();
}

}

It seems to work ok when I start edit activity... I'm creating editor
driver for ContactProxy, editing proxy with save request...

editorDriver = view.createEditorDriver();
editorDriver.edit(getProxy(), createSaveRequest(getProxy()));

... so, all Contact data & list of phones displayed properly...

The problem occured when I try to save a new phone... I see what
flush() in AbstractRequestFactory called twice... One time for
ContactProxy & second - for PhoneProxy... For PhoneProxy I've got a
"java.lang.Throwable: edit() was called with a null Request" which is
true... for ContactProxy I'm callind edit(...) manually with my own
save request, but for PhoneProxy I don't now how to do that as edit()
should be called by RFED, right?

I'm planning to implement all those bells & whistles with validation
later... so I'm trying to use RFED... but, HOW TO MAKE IT WORK for my
case?! :) I spent a lot of time & really stuck on it... cause it seems
I didn't get something important about editor framework...

> Depending on your technical constraints (see above), you have 2 solutions:
>
>    - *enqueue* a persist() call of the created proxy on the request context
>    so that when you fire() it in response to the "save" button being clicked,
>    you'll persist() all created proxies and the ContactProxy.
>    - on the server-side, make sure the Phone instances from the Contact's
>    phones list are correctly persisted: updated or created if needed.

How to *enqueue* a persist() call?

> But it all depends on how your server-side code works, and what it's able to
> do.

At back-end I have simple persist methods with one line like that:
'this.entityManager.persist(this);' :)

Thomas Broyer

unread,
Mar 5, 2011, 4:44:37 PM3/5/11
to google-we...@googlegroups.com
I thought you were saying you're editing the ContactProxy, so why do you have another Driver for the phoneList property?
Also, I don't understand why PhoneListEditor isn't just a IsEditor<ListEditor<PhoneProxy, PhoneEditView>> (your PhoneProxy and PhoneNumProxy seem to be interchangeable, is this a copy/paste bug?)
 
   private ListEditor<PhoneProxy, PhoneEditView> listEditor;

   private List<PhoneNumProxy> displayedList;

   PhoneListEditor(){
      initWidget(container);
      listEditor= ListEditor.of(new PhoneEditorSource());

      driver = GWT.<Driver> create(Driver.class);
      driver.initialize(eventBus, factory, listEditor);
      driver.display(new ArrayList<PhoneProxy>());

      displayedList=listEditor.getList();
   }

   public void addClicked() {
PhoneRequest rq=factory.phoneRequest();
PhoneProxy proxy=rq.create(PhoneProxy.class);
rq.persist().using(proxy);
displayedList.add(proxy);

You're creating a new PhoneRequest to create() and persist() a PhoneProxy (that you never actually persist, as you never fire() the Request, and don't even keep a reference to it)

  public List<PhoneNumProxy> getValue() {
        return new ArrayList<PhoneProxy>(displayedList);
  }

  public void setValue(List<PhoneNumProxy> value) {
for (PhoneNumProxy itemValue : value) {
displayedList.add(itemValue);
}
  }

  public void flush() {
        driver.flush();
  }

}

It seems to work ok when I start edit activity... I'm creating editor
driver for ContactProxy, editing proxy with save request...

editorDriver = view.createEditorDriver();
editorDriver.edit(getProxy(), createSaveRequest(getProxy()));

... so, all Contact data & list of phones displayed properly...

The problem occured when I try to save a new phone... I see what
flush() in AbstractRequestFactory called twice... One time for
ContactProxy & second - for PhoneProxy... For PhoneProxy I've got a
"java.lang.Throwable: edit() was called with a null Request" which is
true... for ContactProxy I'm callind edit(...) manually with my own
save request, but for PhoneProxy I don't now how to do that as edit()
should be called by RFED, right?

No, you're display()ing the List<PhoneProxy> in a distinct RFED (and display(proxy) is equivalent to edit(proxy, null))
 
I'm planning to implement all those bells & whistles with validation
later... so I'm trying to use RFED... but, HOW TO MAKE IT WORK for my
case?! :) I spent a lot of time & really stuck on it... cause it seems
I didn't get something important about editor framework...

Yes: the thing is you only need a single EditorDriver for the whole thing.

In PhoneListEditor, replace "implements ValueAwareEditor<List<PhoneProxy>>, LeafValueEditor<List<PhoneProxy>>" with "IsEditor<ListEditor<PhoneProxy, PhoneEditView>>", that you'll implement by simply returning your listEditor field's value; and let the Editor framework do the rest.

For the "add" to work, you'll have to:
  1. give PhoneListEditor the RequestContext that you gave to the RFED (the one, and only one, used to edit() the ContactProxy); this will be simplified in GWT 2.3 as your PhoneListEditor will only have to implement HasRequestContext and the Editor framework will give it the RequestContext passed to the RFED's edit() (which may be null); in the mean time, you'll have to do it manually, or use the workaround I used (see issue 5892) before I switched to GWT trunk
  2. call .create(PhoneProxy.class) on that RequestContext
 
> Depending on your technical constraints (see above), you have 2 solutions:
>
>    - *enqueue* a persist() call of the created proxy on the request context
>    so that when you fire() it in response to the "save" button being clicked,
>    you'll persist() all created proxies and the ContactProxy.
>    - on the server-side, make sure the Phone instances from the Contact's
>    phones list are correctly persisted: updated or created if needed.

How to *enqueue* a persist() call?

By "enqueuing a call", I mean calling (in your case) persist().using(proxy) on a RequestContext. I use the term "enqueue" because the call won't actually be made (sent to the server) until you fire() the RequestContext.

Vasily

unread,
Mar 6, 2011, 9:47:22 AM3/6/11
to Google Web Toolkit
Well, I've made changes as you described... works perfectly, thx a
lot!.. Now I may add a phone number & it would be persisted upon
Contact's 'save'...

My only concern is 'removing' a phone... 'phoneList' defined in
Contact as One-To-Many with CascadeType.All and each Phone have a Many-
To-One reference on Contact.

I've try listEditor.getList().remove(index) and then persist Contact
entity... but that's not removing Phones from Contact... As I
understood I should remove not phones in Contact.phoneList, but Phone
entities itself...

One stupid question... how to do that in the same way as 'add', when
all changes performing upon 'save'? I'm editing Contact... and use
RequestContext which is ContactRequest... so, I'm not able to call
something like ContactRequest.remove().using(PhoneProxy)...

Am I wrong?
Thx!
> Yes: the thing is you only need a *single* EditorDriver for the whole thing.
>
> In PhoneListEditor, replace "implements ValueAwareEditor<List<PhoneProxy>>,
> LeafValueEditor<List<PhoneProxy>>" with "IsEditor<ListEditor<PhoneProxy,
> PhoneEditView>>", that you'll implement by simply returning your listEditor
> field's value; and let the Editor framework do the rest.
>
> For the "add" to work, you'll have to:
>
>    1. give PhoneListEditor the RequestContext that you gave to the RFED (the
>    one, and only one, used to edit() the ContactProxy); this will be simplified
>    in GWT 2.3 as your PhoneListEditor will only have to implement
>    HasRequestContext and the Editor framework will give it the RequestContext
>    passed to the RFED's edit() (which may be null); in the mean time, you'll
>    have to do it manually, or use the workaround I used (see issue 5892) before
>    I switched to GWT trunk
>    2. call .create(PhoneProxy.class) on that RequestContext
>
> > > Depending on your technical constraints (see above), you have 2
> > solutions:
>
> > >    - *enqueue* a persist() call of the created proxy on the request
> > context
> > >    so that when you fire() it in response to the "save" button being
> > clicked,
> > >    you'll persist() all created proxies and the ContactProxy.
> > >    - on the server-side, make sure the Phone instances from the Contact's
>
> > >    phones list are correctly persisted: updated or created if needed.
>
> > How to *enqueue* a persist() call?
>
> By "enqueuing a call", I mean calling (in your case) persist().using(proxy)on a RequestContext. I use the term "enqueue" because the call won't
Message has been deleted
Message has been deleted

Vasily

unread,
Mar 9, 2011, 2:58:17 PM3/9/11
to Google Web Toolkit
Hi All,

public class Contact {
@OneToMany(cascade=CascadeType.ALL, fetch =
FetchType.EAGER,mappedBy="contact", orphanRemoval=true)
private List<Phone> phoneList = new ArrayList<Phone>();
}

public class Phone {
@ManyToOne(optional = false)
private Contact contact;
}

I've got an exception during persist of Contact entity after edit with
RequestFactoryEditorDriver:
org.springframework.orm.jpa.JpaSystemException:
org.hibernate.HibernateException: A collection with cascade="all-
delete-orphan" was no longer referenced by the owning entity instance:
server.domain.Contact.phoneList; nested exception is
javax.persistence.PersistenceException:
org.hibernate.HibernateException: A collection with cascade="all-
delete-orphan" was no longer referenced by the owning entity instance:
server.domain.Contact.phoneList

It seems, somewhere (in Editor framework?) a new collection of phone's
creating & then used during persist()... That cause an original
collection to become unreferenced & cause that exception.

Could anybody suggest a workaround? Thx!

On Mar 6, 12:44 am, Thomas Broyer <t.bro...@gmail.com> wrote:
> Yes: the thing is you only need a *single* EditorDriver for the whole thing.
>
> In PhoneListEditor, replace "implements ValueAwareEditor<List<PhoneProxy>>,
> LeafValueEditor<List<PhoneProxy>>" with "IsEditor<ListEditor<PhoneProxy,
> PhoneEditView>>", that you'll implement by simply returning your listEditor
> field's value; and let the Editor framework do the rest.
>
> For the "add" to work, you'll have to:
>
>    1. give PhoneListEditor the RequestContext that you gave to the RFED (the
>    one, and only one, used to edit() the ContactProxy); this will be simplified
>    in GWT 2.3 as your PhoneListEditor will only have to implement
>    HasRequestContext and the Editor framework will give it the RequestContext
>    passed to the RFED's edit() (which may be null); in the mean time, you'll
>    have to do it manually, or use the workaround I used (see issue 5892) before
>    I switched to GWT trunk
>    2. call .create(PhoneProxy.class) on that RequestContext
>
> > > Depending on your technical constraints (see above), you have 2
> > solutions:
>
> > >    - *enqueue* a persist() call of the created proxy on the request
> > context
> > >    so that when you fire() it in response to the "save" button being
> > clicked,
> > >    you'll persist() all created proxies and the ContactProxy.
> > >    - on the server-side, make sure the Phone instances from the Contact's
>
> > >    phones list are correctly persisted: updated or created if needed.
>
> > How to *enqueue* a persist() call?
>
> By "enqueuing a call", I mean calling (in your case) persist().using(proxy)on a RequestContext. I use the term "enqueue" because the call won't

Thomas Broyer

unread,
Mar 9, 2011, 4:08:32 PM3/9/11
to google-we...@googlegroups.com
I don't know JPA/JDO much, but wouldn't implementing the setPhoneList as a clear/addAll fix it?

Vasily

unread,
Mar 9, 2011, 5:27:55 PM3/9/11
to Google Web Toolkit
Yes, thank you! I already found a description of that exception and
can confirm, what
modifying of setter for phoneList as you described solving the issue.

Thanks for your time!

-sowdri-

unread,
May 12, 2011, 9:21:34 PM5/12/11
to google-we...@googlegroups.com
Dear All,

Actual code reduced to demonstrate the problem. 

// widget 
public interface LocationPrefEditView extends IsWidget, Editor<LocationPrefProxy>, 
                 HasMask, HasPresenter<Presenter>,
 HasVisibility {

ValueListBox<String> state();
ValueListBox<String> city();
        // .. omitted
}


// in activity

ListEditor<LocationPrefProxy, LocationPrefEditView> editor = ListEditor.of(new ViewSource());
driver.initialize(editor);

CustomerServiceRequest request = requestFactory.getCustomerServiceRequest();
driver.edit(list, request);

List<LocationPrefProxy> displayedList = editor.getList();

// adding a new proxy to list
LocationPrefProxy locationPrefProxy = request.create(LocationPrefProxy.class);
displayedList.add(locationPrefProxy);

request.saveLocationPreference(place.getCustomerId(), CallManager.getInstance().getIdentifier(), list);

// onsave(), elsewhere

// this is always true (driver.isChanged == false always), but driver.isDirty() gives correct value, depending upon the state of the editor
if (!driver.flush().isChanged()) { 
return;
}

// if above check is removed, this always saves empty proxy
driver.flush().fire( /* receiver */ );

#

The same code was working properly in GWT 2.2, I migrated the code to 2.3 today, and I'm facing this issue. 

Any help (or workaround) is appreciated. 

@Thomas 
>> But in 2.3 there will be changes: RFED introduce special support for a HasRequestContext interface, similar to HasEditorDelegate but giving your the RequestContext, so the editor can do a context.create() on the same context that is used to edit the proxies (probably the reason you have the "" exception): http://code.google.com/p/google-web-toolkit/issues/detail?id=5892

Should we do something different for getting list editor working in GWT 2.3??

Thanks, 

Ignacio Baca Moreno-Torres

unread,
Jun 16, 2011, 11:21:01 AM6/16/11
to google-we...@googlegroups.com
Please, can you add the result code? Thanks.

David Sanders

unread,
Jul 4, 2011, 2:48:05 AM7/4/11
to google-we...@googlegroups.com
I'm getting the same problem as George when I tried setting up a create entity form - the entity sent to the server is blank even though I fill out the fields.  The thing is I copied the code from a Spring Roo app but I just cannot get it to work.

I had a look inside the generated delegate code and the methods initialiseSubDelegates() and accept() are empty.  Does this mean I'm not adhering to the editor contract properly?

David Sanders

unread,
Jul 5, 2011, 5:16:00 AM7/5/11
to google-we...@googlegroups.com
Actually nevermind,

I was binding the driver to an interface of my view but didn't add the necessary methods to expose the editors.  I was pulling my hair out because the concrete class exposed the necessary field editors and I couldn't understand why it wasn't working.

Here's where it would be useful if the compiler warned you if you bound to a view that didn't have any sub editors.

Nick

unread,
Jul 30, 2011, 10:50:59 PM7/30/11
to google-we...@googlegroups.com
Vasily, can you post the updated snippet for PhoneListEditor and related UI code.

poseidonjm

unread,
Feb 16, 2012, 10:50:19 PM2/16/12
to google-we...@googlegroups.com

Daniel Mauricio Patino León

unread,
Feb 17, 2012, 4:30:48 PM2/17/12
to google-we...@googlegroups.com
Buen ejemplo de GXT 3.0 y GWT 2.4.

Sin duda usar GXT resuelve mucho de lo que con GWT tendrías que codear por ti mismo.
Espero que la versión completa este lista pronto. 


Saludos.

2012/2/16 poseidonjm <posei...@gmail.com>

--
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.



--
ISC. Daniel Mauricio Patiño León.
Director ejecutivo
Liondev S.A. de C.V.



Reply all
Reply to author
Forward
0 new messages