2012-04-26 47 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.

相关问题