How would I use button in the following situation in grails? -


i returning map value contain multiple items. map follows:

def mylist = []  //some code obtain list  list << ["id": id,"name": name,"code": scode, "runtype": x ] return [items: list] 

in gsp page using following code print them out in web page.

            <%             def counter = 0              (i in items) {                 counter = counter + 1                  println("<td>" + + "</td>" + "\n")                  if (counter == 1) {                     println("</tr><tr>")                     counter = 0                 }             }          %> 

and output looks follows:

[id:i-d0f5, name:es_test_1b_110.test.com, code:16, runtype:on demand] [id:i-7890, name:namc-qc.test.com, code:16, runtype:on demand] [id:i-ee56, name:abcdef.test.com, code:16, runtype:on demand] [id:i-c41e, name:backup.grails.test.com, code:80, runtype:on demand] 

what need add button each of values printed (so if 6 servers printed 6 buttons show , if 10 servers printed 10 buttons show up) using button pass id start , stop server.

grails has powerful built-in gsp tags come in quite handy here. example:

<g:each in="${items}" var="i">   <tr>     <td>${i.id}</td>     <td>${i.name}</td>     <td>${i.code}</td>     <td>${i.runtype}</td>     <td><a class="button" href="${createlink(controller: '<controllername>', action: 'start', id: i.id)}">start</a></td>   </tr> </g:each> 

there are, of course, many other ways approach this, hope start. more, see these sections in grails ref doc: each, createlink


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -