开发者

Editing Collections with GWT Editors and RequestFactory

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 Questio开发者_运维百科n, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜