*Edit* I didn’t know about ‘Add Dynamic Property’ feature of Idea, that is exactly what I wanted. Thanks Sergey
I love the fact how Intelli-J recognizes the type of variables put into the model from a common controller and allows autocomplete right in the GSP.
For example if I have a controller method
def mymethod = {
MyDomain myDomainInstance =
.... logic ...
[myDomainInstance: myDomainInstance]
}
In my corresponding mymethod.gsp, Intelli-J will autocomplete methods on ${myDomainInstance} from the MyDomain bean.
However consider a shared template that uses the same domain class and could be rendered via
<g:render template="/shared/somesharedtemplate" model="['myDomainInstance': myDomainInstance]">
When I am editing /shared/_somesharedtemplate.gsp, ${myDomainInstance} is not recognized as something Intelli-J knows about (but of course works fine when Grails runs). Is there any declaration or anything I can add to the GSP to hint it?
Try to remove quotes around variable name in value of ‘model’ attribute. IDEA does not recognize model variable defined inside quotes. It’s a bug: http://youtrack.jetbrains.net/issue/IDEA-80041.
Also you can add a dynamic property ‘myDomainInstance’ for page _somesharedtemplate.gsp . Press Alt+Enter on unrecognized reference then select ‘Add Dynamic Property ‘myDomainInstance” intention.