2012-04-05 2 views
0

1つのページに同じテンプレートをレンダリングします。このテンプレートは、パラメータ値(3または4)に応じて値を表示する必要があります。 ビューがある -渡されたモデルのパラメータ値に応じてテンプレート値をレンダリングする方法は?

<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> 

コントローラが持っている -

テンプレートコードで全体の適切な値を表示する方法
[ total3:totalValue3,total4:totalValue4] 

を -

<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> 

答えて

2

ヨは変更する必要があります。

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

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

そして、あなたのテンプレートで置き換える:

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

をすることにより:

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

ドキュメントのチェックのために:あなたはここに配列またはオブジェクトを使用することができることをhttp://grails.org/doc/2.0.x/ref/Tags/render.html

+0

として使用します。 – sana

2

知っていますか?

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

のような、私のためにthanks.worked

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

は知りませんでした。本当に助かりました。変更を行います。 – sana

関連する問題