2012-04-26 40 views
0

我想在我的gsp的不同id上觸發相同的對話框。 所以這裏是代碼:在標籤屬性中使用scriptlet或EL(Grails UI Plugin)

<div class="yui3-widget-bd"> 
    <g:each in="deployments" status="index" var="workflow"> 
     <% def id = "reloadFile"+index %> 
     <gui:dialog title="Reload File" form="true" modal="true" 
        controller="admin" action="reloadFile" 
        triggers="[show:[id:'${id}', on:'click']]"> 
     <p>To reload the file, please...</p><br /> 
     <input type="file" id="deploymentFile" name="deploymentFile" /> 
     </gui:dialog> 
    </g:each> 
</div> 

的問題是scriptlet代碼:

triggers="[show:[id:'<%=id %>', on:'click']]" 

是沒有得到評估。 偵聽在生成的HTML源事件中的JavaScript看起來像這樣:

YAHOO.util.Event.addListener("${id}", "click", GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce.show, GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce, true); 

所以,我怎麼能管理,源看起來像這樣? :

YAHOO.util.Event.addListener("reloadFile1", "click", GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce.show, GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce, true); 

謝謝。

+0

除去$ {id}周圍的單引號怎麼辦? (triggers =「[show:[id:$ {id},on:'click']]」) – Todd 2012-04-26 12:46:37

+0

謝謝你的回答託德,但那不起作用。我得到一個GrailsTagException。還有什麼想法? – Paul 2012-04-27 01:16:48

回答

1

一樣的JSP:

  • 如果要執行一些代碼

    <%DEF東西=真正%>

  • 如果你想使用的執行

    的回報

    <%= =? 「這是一個真理聲明」:「這是假的」%>

要注意的是這可能是代碼味道和代碼應該是在一個域中,控制器或標記庫的病例99.9%。

Here's the reference documentation for more info.

相關問題