grails - 在标记的属性内使用scriptlet或EL(Grails UI插件)

标签 grails tags el gsp scriptlet

我想在gsp中的不同ID上触发相同的对话框。
所以这是代码:

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

谢谢。

最佳答案

与jsps相同:

  • 如果要执行一些代码

    <%def something = true%>
  • 如果要使用执行返回

    <%=什么? “这是一个事实陈述”:“这是错误的”%>

  • 请注意,这可能是代码异味,并且代码应在99.9%的情况下属于域, Controller 或taglib。

    Here's the reference documentation for more info.

    关于grails - 在标记的属性内使用scriptlet或EL(Grails UI插件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10331196/

    相关文章:

    Azure PowerShell - VM 标记报告

    python - 如何使用Python Beautiful Soup获取html的标签名称?

    Java EL 表达式 : "property (num1|str) not readable on type (int|String)"

    javascript - 在 JavaScript 中访问 Java/Servlet/JSP/JSTL/EL 变量

    grails - 从Grails 2.4.4升级到Grails 2.5.0时grails.gorm.TestCriteriaBuilder出现问题

    grails - 从命令行运行时grails使用哪个常规

    java - 在 java 中包含 css(用于 href 标签)

    java - 在 JSP EL 中通过常量获取变量不起作用

    grails - java.lang.NoSuchMethodError:com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I

    spring - 在grails应用程序中使用Spring Security限制页面 View