gwtで基本的なエディターをセットアップしようとしています。すべて正常に動作し、エディターはデータを表示して保存しますが、もう一度保存しようとすると(つまり、保存ボタンを2回押すと)、2回目の保存で「リクエストは既に進行中です」というエラーがスローされますが、最初はエディターはデータを正しく保存します。
//
//Methods that edit and save the editor, located in ComposerEditorContainer class
//
public void edit(RequestContext requestContext) {
editorDriver = GWT.create(Driver.class);
editorDriver.initialize(requestFactory, composerEditor);
editorDriver.edit(composer, requestContext);
}
public void save() {
ComposerRequest composerRequest = (ComposerRequest) editorDriver
.flush();
ComposerProxy newProxy = composerRequest.edit(composer);
composerRequest.persist(newProxy).fire();
}
//
//Events in a presenter that save and initialize the editor
//
eventBus.addHandler(SaveButtonClickedEvent.TYPE,
new SaveButtonClickedEventHandler() {
@Override
public void onSaveButtonClicked(SaveButtonClickedEvent event) {
((ComposerEditorContainer) composerEditorContainer)
.save();
}
});
//This method gets the ComposerProxy from the event and initializes the editor in ComposerEditorContainer (above)
//
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) {
ComposerEditorContainer editorContainer = new
ComposerEditorContainer(
requestFactory, arg0);
editorContainer.edit(requestFactory
.getComposerRequest());
view.clear();
view.addWidget(editorContainer);
composerEditorContainer = editorContainer;
}
});
}
});
//2回目の保存時に表示されるエラー
原因:java.lang.IllegalStateException:リクエストはcom.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.checkLocked(AbstractRequestContext.java:960)atcom.google.web.bindery.requestfactoryですでに進行中です.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:510)at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.edit(AbstractRequestContext.java:502)at com.google.test.client.editor .ComposerEditorContainer.save(ComposerEditorContainer.java:58)at com.google.test.client.presenter.BrowserDetailPresenter $ 1.onSaveButtonClicked(BrowserDetailPresenter.java:48)at com.google.test.client.event.SaveButtonClickedEvent.dispatch(SaveButtonClickedEvent。 java:17)