使用 GWT 编辑器和 RequestFactory 编辑集合
请参阅原始问题了解上下文。
其他上下文:
- Objectify-Appengine 用于持久性。
FormProxy
和QuestionProxy
属于 EntityProxyQuestionDataProxy
类型,其子类型属于ValueProxy
类型- 所有编辑器都实现
HasRequestContext
,对于QuestionData
子类型编辑器,从父级显式调用HasRequestContext.setContext()
。
第一个问题与集合有关,第二个问题与多态类型有关。我不确定问题是否出在我使用编辑器或 RequestFactory 的方式上。由于数据不存在于 RPC 负载中,我们可以排除持久性设置。
问题
RPC 请求中 QuestionProxy 的值全部为 null(如果 QuestionProxy 是新创建的,则可以)
问题
从表单中添加/删除 Questions
的正确方法是什么。使用编辑器时,调用 Question
、Form
和 QuestionData
的创建、编辑、更新方法的顺序是什么?
当前解决方案
添加问题功能(在活动中):
@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);
}
要删除问题,我在问题中标记一个标志,这会将其从服务器上的列表中删除,然后将其删除。 (hack)这仅适用于已经保存的问题。
See the orignal question for context.
Additional Context:
- Objectify-Appengine is used for persistence.
FormProxy
andQuestionProxy
are of type EntityProxyQuestionDataProxy
and its subtypes are of typeValueProxy
- All Editors implement
HasRequestContext
, and in the case ofQuestionData
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论