Editing Collections with GWT Editors and RequestFactory

帅比萌擦擦* 提交于 2019-12-12 10:07:25

问题


See the orignal question for context.

Additional Context:

  • Objectify-Appengine is used for persistence.
  • FormProxy and QuestionProxy are of type EntityProxy
  • QuestionDataProxy and its subtypes are of type ValueProxy
  • All Editors implement HasRequestContext, and in the case of QuestionData subtype Editors, HasRequestContext.setContext() is called explicitly from the parent.

The first problem has to do with Collections, and the second has to do with Polymorphic types. I'm not sure if the problem is with the way I'm using Editors or RequestFactory. Since the data isn't present in the RPC payload we can rule out the persistence setup.

Problem

Values for QuestionProxy are all null in RPC request (if QuestionProxy is newly created, ok otherwise)

Question

What is the correct way to add / remove Questions from the form. What is the sequence of calling create, edit, update methods for Question, Form, and QuestionData while using Editors.


Current Solutions

The add question functionality (in the activity):

@Override
public void addQuestion(final QuestionEditor questionEditor) {
    final QuestionProxy proxy = theOneAndOnlyOneContextForEditing.create(QuestionProxy.class);
    final QuestionRequest dpr = theOneAndOnlyOneContextForEditing.append(clientFactory.getRequestFactory()
            .qestionRequest());
    dpr.updateQuestion(proxy);
    questionListEditor.asEditor().getList().add(proxy);
}

To remove a question I mark a flag in the question, which will remove it from the list on the server, and delete it. (hack) This only works for questions which have already been saved.

来源:https://stackoverflow.com/questions/7095567/editing-collections-with-gwt-editors-and-requestfactory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!