how to render template value depending on model param value passed?

Go To StackoverFlow.com

0

I want to render same template on one page which should display the value depending on the param value(3 or 4). View is --

 <td >
<g:render template="gdxqStatusTemplate" model="[param:3]" /> </td>
</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td >
<g:render template="gdxqStatusTemplate" model="[param:4]" /> </td>
</td>

Controller has -

 [ total3:totalValue3,total4:totalValue4]

how to show the appropriate value of total in template code -

<table >
    <tr ><td class="InputText" nowrap><b>   MessageQ Status,/td>

<tr> <td class="NoLight" nowrap>Total MessageQ : ${total+params}***/* IT SHOWS "total4" NOT THE VALUE.*/***
</td></tr>
<tr height=30></tr>
</table>
2012-04-05 17:52
by sana


2

Yo must change:

 <g:render template="gdxqStatusTemplate" model="[param:3]" />

By

 <g:render template="gdxqStatusTemplate" bean="${total3}" />

And in your template replace:

 <td class="NoLight" nowrap>Total MessageQ : ${total+params}</td>

By:

 <td class="NoLight" nowrap>Total MessageQ : ${it}</td>

For documentation check: http://grails.org/doc/2.0.x/ref/Tags/render.html

2012-04-05 18:00
by Ernesto Campohermoso
thanks.worked for me - sana 2012-04-05 18:41


2

Do you know that you can use arrays or objects here? like

model: [total: [null, null, totalValue3, totalValue4]]

and use as

<td class="NoLight" nowrap>Total MessageQ : ${total[params]}</td>
2012-04-05 18:03
by Igor Artamonov
did not know.thanks for suggestion,really helpful. will make change - sana 2012-04-05 18:42
Ads