GrailsDomainClass 类有两种方法:getProperties
和getPersistentProperties
我有一个域类 ( MyDomainClass
),其中包括:
static transients = {computeStuff}
float computeStuff(){
def thisCouldChange = 3.1
return thisCouldChange //it actually does things but not of consequence to my question
}
好的,我采用了默认索引页面并对其进行了修改以列出所有属性MyDomainClass
:
<g:each var="d" in="${grailsApplication.domainClasses.sort { it.fullName } }">
<h2>${d.fullName}</h2>
<g:each var="f" in="${d.properties.sort { it.fieldName } }">
<br>${f.fieldName }
</g:each>
</g:each>
行。这行得通,但它没有得到任何瞬态属性。我已经尝试过 d.properties 和 d.persistantProperties ,它们似乎给了我相同的结果。在此先感谢您的帮助!!
我需要称它为 getComputeStuff 吗?
我现在已经更改了我的域类以包含它,但仍然没有取回瞬态 computeStuff
static transients = ['computeStuff']
float getComputeStuff(){
def thisCouldChange = 3.1
return thisCouldChange //it actually does things but not of consequence to my question
}
这似乎没有任何区别。