如何将数组从 grails / jdo 返回到 Flex
这看起来很简单,但我还没有让它发挥作用。我正在谷歌应用程序引擎上使用 grails 构建我的应用程序。这几乎需要您使用 JDO。
我正在从 flex 到我的应用程序进行 HTTP 调用。我在 grails 端调用的操作看起来像这样,所以
def returnShowsByDate = {
def query = persistenceManager.newQuery( Show )
def showInstanceList = query.execute()
return (List<Show>) showInstanceList
}
我尝试只返回“hello from grails”,效果很好。我也尝试过以下
return showInstanceList
JDO 文档说 query.execute() 返回一个集合。为什么我不能把它还给 Flex 我不知道。
有什么想法吗?
<块引用> <块引用> <块引用>在尝试了更多之后,我能够通过让 grails 将对象转换为 JSON 或 XML 来获取结果事件
希望我可以只返回一个该死的 ArrayList。那会更好,但是哦,好吧。
this seems really simple but I haven't gotten this to work. I am building my app with grails on google app engine. This pretty much requires you to use JDO.
I am making an HTTP call from flex to my app. The action that I am calling on the grails end looks like so
def returnShowsByDate = {
def query = persistenceManager.newQuery( Show )
def showInstanceList = query.execute()
return (List<Show>) showInstanceList
}
I have tried just returning "hello from grails" and that works just fine. I have alos tried the following
return showInstanceList
the JDO docs say the query.execute() returns a collection. Why I cant just return that to Flex I have no clue.
Any thoughts?
after playing around with this some more I was able to get a result event back by have grails convert the object to JSON or XML
wish I could just return a damn ArrayList. That Would be better but oh well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我找到了根本问题,我正在回答我自己的问题。
我注意到在使用 JSON 内容时也遇到了错误事件,因此我启动了浏览器并转到 grails 提供的列表视图。然后我向 Flex 请求了数据,结果成功了。
长话短说,如果我没有先进入 html 视图,persistenceManager 将为 null,因此在从 Flex 调用的方法中我添加了以下内容。
现在一切正常。
OK so I found the fundamental problem and I am answering my own question.
I noticed that I got a fault event when using the JSON stuff too, so I launched a browser and went to the list view that grails provided. Then I requested data from Flex and it worked.
Long story short persistenceManager was null if I didn't go to the html view first so in my method that is being called from Flex I added the following.
all works well now.