Grails< g:if> in< g:select> [英] Grails <g:if> in <g:select>
问题描述
我在 .gsp
文件中有< g:select>
。但不同于任何普通的< g:select>
,这个人会拥有属性 disabled =
以下代码:
< / p> g:select name =test
from =$ {[foo1,foo2]}
它返回一个错误: Grails标签[g:select]未关闭
但是,当我将其更改为此项时:
< g:select name =test
from =$ {[mu1,mu2,mu3]}
$ {if(true){println disabled = \\}} />
它返回了这个错误:必须引用属性值。
$ b
这两个错误消息都在异常下, org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
问题是我们该如何做这项工作?有没有可能的答案,而不使用自定义的TagLib?
GSP表单字段标签treat disabled
作为一个布尔属性,所以你可以说
< g:select .... disabled = $ {true}/>
通常情况下,您应该可以在通常的Groovy-truth规则下使用任何表达式,但我相信它会使字符串true和false的特殊情况(后者在Groovy-truth规则下通常被认为是 I have this Following the code: It returned an error: But when I change it into this: It returned this error: Both of the error message are under the exception, The question is how could we make this work? Is there a possible answer without using a custom TagLib? The GSP form field tags treat Generally you should be able to use any expression under the usual Groovy-truth rules but I believe it makes a special case for the strings "true" and "false" (the latter would normally be considered
这篇关于Grails< g:if> in< g:select>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! true ,作为非空字符串)。如果有疑问,你可以总是说:
$ b $ pre $ disabled =$ {(someExpression)as boolean}
<g:select>
in a .gsp
file. But unlike any ordinary <g:select>
's this one would have the attribute disabled=""
if a certain condition is met.<g:select name="test"
from="${["foo1","foo2"]}"
<g:if test="${true}">disabled=""</g:if> />
Grails tag [g:select] was not closed
<g:select name="test"
from="${["mu1","mu2","mu3"]}"
${ if(true) { println "disabled=\"\"" } }/>
Attribute value must be quoted.
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
disabled
as a boolean property, so you can say<g:select .... disabled="${true}" />
true
under Groovy-truth rules as a non-empty string). If in doubt you can always saydisabled="${(someExpression) as boolean}"