Tuesday, May 29, 2012

Re: Editor persist throws "A request is already in progress "

Modified the code , it is working now. Thanks for the help

//
//Method in the ComposerEditorContainer class
//
public ComposerProxy save() {
ComposerRequest composerRequest = (ComposerRequest) editorDriver
.flush();
final ComposerProxy newProxy = composerRequest.edit(composer);
composerRequest.persist(newProxy).fire(new Receiver<Boolean>() {
public void onSuccess(Boolean arg0) {
if (arg0)
presenter.updateEditor();
}});
return newProxy;
}
//
//Method in the presenter
//
public void updateEditor() {
requestFactory = GWT.create(AppRequestFactory.class);
requestFactory.initialize(new SimpleEventBus());
ComposerRequest request = requestFactory.getComposerRequest();
Request<ComposerProxy> req = request.findComposer(selectedComposer
.getId());
req.fire(new Receiver<ComposerProxy>() {
public void onSuccess(ComposerProxy arg0) {
selectedComposer = arg0;
editorContainer.setComposer(selectedComposer);
editorContainer.edit(requestFactory.getComposerRequest());
view.clear();
view.addWidget(editorContainer);
}});
}




public void registerEvents() {
eventBus.addHandler(SaveButtonClickedEvent.TYPE,
new SaveButtonClickedEventHandler() {
@Override
public void onSaveButtonClicked(SaveButtonClickedEvent event) {
selectedComposer = ((ComposerEditorContainer)
editorContainer).save();
}
});

eventBus.addHandler(BrowserItemClickedEvent.TYPE,
new BrowserItemClickedEventHandler() {
@Override
public void onBrowserItemClicked(
BrowserItemClickedEvent event) {
requestFactory = GWT.create(AppRequestFactory.class);
requestFactory.initialize(new SimpleEventBus());
ComposerRequest request = requestFactory
.getComposerRequest();
Request<ComposerProxy> req = request.findComposer(event
.getclickedItem().getValue());
req.fire(new Receiver<ComposerProxy>() {
public void onSuccess(ComposerProxy arg0) {
selectedComposer = arg0;
editorContainer.setComposer(selectedComposer);
editorContainer.edit(requestFactory
.getComposerRequest());
view.clear();
view.addWidget(editorContainer);
}
});
}});
}

On 29 mayo, 15:20, Thomas Broyer <t.bro...@gmail.com> wrote:
> On Tuesday, May 29, 2012 7:09:39 PM UTC+2, jmbz84 wrote:
>
> > Thanks for the reply,
>
> > In order to create a new RequestContext what I must do is call the :
>
> >   editorContainer.edit(requestFactory.getComposerRequest());
>
> > before I save for the second time?
>
> > It means that I have to re-initialize the editor once I save it.
>
> Absolutely. In general, you'd have the save() method return the modified
> proxy (in case another user modified it too, particularly if he modified
> fields that the current user didn't touch) and edit() it from the
> Receiver's onSuccess.

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment