Editing Collections with GWT Editors and RequestFactory
Asked Answered
B

0

2

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.

Bidarka answered 17/8, 2011 at 15:38 Comment(1)
What's the relationship between Form and Question ?Tempa

© 2022 - 2024 — McMap. All rights reserved.