GRAILS g:each problem -
i cant g:each work. trying iterate on never works = doesnt generate html.
index.gsp
<g:each var="i" in="${userlist}" controller="user"> <li>item ${i.name}</li> </g:each> usercontroller.groovy
class usercontroller { ... def userlist = { user.list() } ... } then have user.groovy filled number of users..
what supposed write in in="${.....}" iterate example on users declared user.groovy ? have tried : user, users, user.list() ...
thanks
edit:
let's have
def findone { [users : user.findallbynamelike("%petr%") } in usercotroller.
how use g:each because
<g:each var="user" in="${findone}"> won't anything..
in example. userlist closure, it's action name, i'm assuming you're accessing http://localhost:8080/appname/user/userlist
if return controller action rendered in gsp, has in map, "model". each value in map exposed in gsp using map key name. controller action corresponding gsp be
def userlist = { [users: user.list()] } and can iterate with
<g:each var="user" in="${users}"> <li>item ${user.name}</li> </g:each> the name doesn't matter - has same in model map in gsp.
Comments
Post a Comment