Grails - entityName is null
Grials newbie - my boilerplate, gen开发者_StackOverflow中文版erated view code is returning null when trying to resolve the entityName argument passed to the g:message tag. So...
<g:message code="default.show.label" args="[entityName]" />
renders as "Show null" instead of "Show [the domain class name]"
Any idea what may be going on here, or suggestions on how to diagnose this? I have been making incremental changes to both the views and the domain classes but wouldn't expect this to have made any difference
entityName is a variable and set by the set tag lib, which must placed before the message tags using this variable. e.g.
// first define the entity name var
<g:set var="entityName" value="${message(code: 'test', default: 'TEST')}"/>
// display msg
<g:message code="default.show.label" args="[entityName]" />
maybe you forget to define this var or accidentally deleted this line of code.
I think the above example expalined it properly. However for simple understanding you can check this:
Simple VARIABLE which holds some value.. to do tht we use the follwoing tag
sf
Here, var is having : Nothing but a Variable name
and value is having: Nothing but a Value of it.
Basically I am setting Value "User" to the variable "entityName"
So Declaration and Initialization of variable is done.
2.Now, Usage of it--> using the Following Tag
Here, code's value "default.list.label" represents the i18n message.properties file. Where args's value (i.e "User") will be sent as a argument.
精彩评论