开发者

How do I return an Array from grails / jdo to Flex

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.


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.

if(!persistenceManager) 
        def persistenceManager

all works well now.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜