In my controller class have the following code
class MyController {
def flickrService
def index = {
def data = flickrService.search {
tags 'tag,tag2,tag3'
page 3
perPage 14 // Look ma!
}
[urls:data.urls,page:data.page,pages:data.pages]
}
}
I have also created an index.gsp file.
As I am new to groovy grails – i could not figure it out how to access data returned by flickrservice in the view. Can I just access “data” defined above in the index view or I need to set it in the controller before I can loop through the returned data? Any help would be highly appreciated. Thanks
Yes, now you can access data from the view, for example,in index.gsp:
Generally saying, grails return the last value in function by default, so if you want to access many data, you can do like this:
Then you can access ${view_data},${view_data1},${view_data2} in view.