Custom Tag Names Unresolved?
Hi,
I created my first Grails custom tag and while it functions properly when I run the Grails application, the tag name always shows up in red with the error message "Canot resolve Grails tag".
This tag lib has its own namespace, but before I added the namespace def to the TagLib class, the problem was the same (with the GSP code using the namespace prefix g: instead of the custom namespace, as it does now). In other words, the use of a separate namespace for the tag lib didn't change anything.
Is this a configuration problem of some sort or a bug in JetGroovy?
Randall Schulz
Please sign in to leave a comment.
Hello Randall,
It's hard to tell without actually seeing your code...
I don't understand.
I put a file, TauTagLibs.groovy in the grails-app/taglib directory. It defines a tag named "cb". I use that tag in a couple of GSP pages and it works, but JetGroovy is giving unresolved error.
Before I added { ... static namespace = "tau" ... } I used <g:cb ...> in the GSP and after adding the namespace definition I use <tau:cb ...>. The tag is working fine when the Grails application runs (with or without the namespace).
Randall Schulz
Fixed, thank you
Great, thanks.
RRS
Eugene,
When might we expect a release with this fix included?
Randall Schulz
Friday as usually?
OK. I hadn't really noticed you were on a weekly release schedule.
My tag library is growing, and my GSP pages are getting redder...
Randall Schulz
Hi,
I'm finding that neither 0.1.11420 nor 0.1.11507 have fixed this problem. All my custom tags are still colored red and labelled "Cannot resolve Grails tag '...'".
Does the GSP file require some kind of "import" declaration? The Grails class that implements them is not in a package, has the proper name and Grails has no trouble finding and executing the tags when I run the application.
Randall Schulz
Nope, no imports are needed. My wild guess is that the tag name classes are not found in your project. Could you check it with ctrl-N?
Ctrl+N followed by (in my case) "ClifTagLib" (which is in the .../taglib/ directory) presents me a pop-up showing both ClifTagLib and the ClifTagLibTests.
Randall Schulz
Do you custom tag classes include 'namespace' field declaration?
Yes, of course. And as I said earlier, it's the same whether there's a custom namespace or not.
Randall Schulz
I'm finding that *all *GSP tags are showing red as "Cannot resolve Grails tag xxx", including <g:each>, <g:link> ,etc. Is there a setting I must configure or is this a bug? I'm using IDEA #7343 and JetGroovy 0.1.11565.
Nope.
I still suspect something is amiss in your installation.
RRS
Thanks for the advice. I uninstalled everything and re-installed and all is well. (Except that I'm also seeing custom tag names unresolved. My only "custom" tag is <g:resourceLinkTo> from the StaticResources plugin.)
I upgraded to grails-1.0-RC1 today and now again ALL gsp tags are shown red and unresolvable (e.g. Cannot resolve Grails tag 'g:if'). Any idea what causes this, or what I've done wrong?
I'm not thrilled about doing another complete un-install and re-install. I've updated "grails installation directory" in the JetGroovy plugin, and upgraded to 0.1.11638 (and Selena #7343).
I'm finding another problem: I see a warning "Cannot assign 'groovy.lang.closure' to 'java.lang.Object" all over nearly every grails file, i.e. in all of my Controller and Domain classes. Any suggestions about what I've done wrong would be greatly appreciated.
I apologize for "talking to myself" in this thread and wasting other people's time. I have found my problem. (I had to add the grails lib and bin directory in Module Settings -> Project Settings -> Libraries -> Attache Jar Directories. I had expected that configuring the JetGroovy plugin made this step unnecessary.)
What is the status of the original question? Is there a way to configure JetGroovy to resolve custom tag names?
Yes, the key, at least for me, was to add Content Root directories for all those directories in your Grails application that hold either Groovy, Java or GSP files. In particular, for the purpose of getting custom tag libraries recognized, you have to ad the appropriate .../grails-app/taglib directory. Furthermore, once you add a Content Root for each such directory, you must also mark the directory as a "Sources" directory.
After I did that, JetGroovy recognized my custom tags.
Randall Schulz
Can you please clarify what "Content Root' means? I've added the plugin taglib directory as a library source (Project Settings -> Libraries -> Sources [using the 'Attach Sources...' button) but this has not solved my issue. I'm also confused my the last part about "mark the directory as a "Source" directory' (but my confusion may be because I don't understand what Content Root is).
Thanks for you help (and patience).
Brad
Brad,
Here's the image that Ilya Sergey (one of the JetGroovy developers) gave me to illustrate a working sample project configuration with a Grails application module.
Randall Schulz
Attachment(s):
sources.jpg