Using taglib TEI in a JSP does not appear to be working Follow
I have a JSP project which uses a 3rd party taglib which injects certain objects into the pageContext at runtime. I'm doing development using Apache Sling. One of the tags I'm trying to work with is the <sling:defineObjects/> tag. The TLD file defines a TEI file correctly, and it is there.
The syntax checker is correctly handling the tag itself. It can code assist with parameters. If I ctrl-click on the tag, it takes me to the TLD file. If I ctrl-click on the class specified in the <tei-class> tag, IntelliJ takes me to the correct class file, so that much is working. But in my JSP file itself, while the tag is handled properly, I'm still getting the syntax checker marking the newly defined implicit variables as red/error. Does IntelliJ need some further hinting? Sling projects are NOT set up like other web projects, so I wonder if that's an issue? For example, I can't define a web facet. Is that required?
I'm using 9.0.4.
Thanks for any help,
--David
Message was edited by: David Levine
Please sign in to leave a comment.
Could you provide a code snippet? Scriptlets like
<%
String foo = (String) pageContext.getAttribute("foo");
%>
work fine for me.
I'm sorry, I misspoke. Instead of pageContext, I meant implicit objects. The tag adds implicit objects which are also identified in a TEI class.
So an example piece of code from a JSP file would be something like:
If I ctrl-click on the "sling:defineObjects" tag, IntelliJ correctly opens the TLD file. In the TLD file I can ctrl-click on the classes defined in the <tag-class> and <tei-class> nodes and both will correctly open the class file. So it looks as if IntelliJ sees everything properly. And the code completion works with the tag itself. When I type "<sling:" it instantly pops up with the possible completions. But for some reason the implicit object "currentNode" that is created by the defineObjects tag is not being resolved by IntelliJ.
Hi David,
I am facing the exact same problem i.e. currentNode is not recognized even after doing <sling:defineObjects/>. I was wondering if you found any solution for this.
Hi
Same issue here... did you find a solution for this problem?
Regards
Bump; I am running into the same issue.
Using IntelliJ IDEA Ultimate 12.1.4
I also had the same issue for weeks.. am using IDEA 12
Just make sure you have all the taglib dependency jar files.. in other words there should be no errors ( red marks ) in IDE editor when you open the taglib file....
Same happens to me with Idea 13:
It's basically a POC, so i can post the structure and files. It works when deploying the war, but the IDE doesn't recognize the TEI implicit variable
Project
----------
- lib
- jsp-api.jar
- servlet-api.jar
- src
- org
- TestTag.java
- TestTEI.java
- web
- WEB-INF
- jsp
- test.jsp
- tld
- test.tld
- web.xml
Files
-------
TestTag.java:
[...]
public final class TestTag extends BodyTagSupport {
public TestTag(){
super();
}
public int doStartTag()
throws JspException
{
String result = null;
result = (String)this.pageContext.getAttribute("test", PageContext.REQUEST_SCOPE);
if (null == result){
result = "Hello World";
}
this.pageContext.setAttribute("test",
result, PageContext.PAGE_SCOPE);
return super.doStartTag();
}
}
TestTEI.java
[...]
public final class TestTEI extends TagExtraInfo {
public TestTEI(){
}
public VariableInfo[] getVariableInfo(TagData paramTagData){
return new VariableInfo[] {
new VariableInfo("test", "java.lang.String", true,
VariableInfo.NESTED)
};
}
}
test.tld
<?xml version="1.0" encoding="ISO-8859-1"?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<tlib-version>1.0</tlib-version>
<short-name>test</short-name>
<uri>http://mycompany.com</uri>
<tag>
<name>init</name>
<tag-class>org.TestTag</tag-class>
<tei-class>org.TestTEI</tei-class>
<body-content>JSP</body-content>
</tag>
</taglib>
web.xml
[...]
<jsp-config>
<taglib>
<taglib-uri>tld/test</taglib-uri>
<taglib-location>/WEB-INF/tld/test.tld</taglib-location>
</taglib>
</jsp-config>
[...]
test.jsp
<%@ taglib uri="tld/test" prefix="test" %>
<test:init>
<%= test %>
</test:init>
Actually i got the code hint for <test:init> but i got a "cannot resolve symbol 'test'" on the scriptlet. As i said, it works when deploying it on tomcat
Hello.
I've copied all the source code/markup you have provided into my test project and see no problem.
Could you pack the whole test project where the problem occurs on your side and attach? Maybe the project settings play a part.
Thank you,
Alexander.
I'm experiencing the same problem with TEI and scripting variables.
Tested on MacOSX 10.9 +
IntelliJ 12.1.6 Ultimate (129.1359),
IntelliJ 13 Ultimate (133.193)
- I created a new project, type: Java
- Add Web Application support (checked create web.xml)
- Added dependency on servlet-api.jar and jsp-api.jar (from Tomcat 7 lib dir)
- Created the two classes above (org/TestTag.java, org/TestTEI.java)
- Created WEB-INF/tld/test.tld
- Added reference in web.xml
- Updated index.jsp with test code
- Rebuilt project
After the above steps, the 'test' variable in the scriptlet is highlighted in red.
Project directory is attached.
Attachment(s):
teitest3.zip
Thank you. Short off-topic: is there "1" macro in your Settings / Path Variables? Opening attached project requires to define it (I can work without it for now).
Thanks,
Alexander.
Indeed, there is a "1" macro in my path settings. Weird.
I see the red just after the rebuilding the project. However, after closing and reopening of the project the error goes away.
The fact that reopen is required is anyway a defect or limitation, I will report it. But please confirm that reopening the project helps on your side to make sure we observe the same issue.
Thank you,
Alexander.
And what is its value?
I'm sure this does not relate to TEI issue, just hoping we could catch one more.
Alexander.
It's unrelated. It was defined as "2'. I have no idea why.
That's different behavior than I'm seeing. For me, "test" remains "highlighted red" after closing and re-opening the project (also after quitting and restarting IntelliJ).
I rebuilt the project without the "1" macro and saw no change. Any diagnostics I can enable? I'm going to try a fresh IntelliJ install on Windows (instead of MacOS X) with the same project.
It works fine after a fresh install of IntelliJ 13 on Windows. I'm going to try nuking my prefs on MacOS X (By launching IntelliJ as a guest user account)
Edit: Did not work after nuking ~/Library/Preferences/Intellij13 on OS X.
Edit2: Works on a fresh IntelliJ Linux install too.
Message was edited by: Chris Thielen
I installed a fresh copy of IntelliJ on:
Linux (Ubuntu 13.10) (TEI works)
Windows XP (TEI works)
Mac OS X Mavericks 10.9.1 (TEI does NOT work)
For Mavericks, I installed a brand new copy of Mavericks 10.9.1, JDK 1.7.0_45 and IntelliJ IDEA 13. I downloaded Java 6 runtime when the IDEA installer asked me to.
Edit: I tried something based on IDEA-75293 ... On Mavericks, if I tell IntelliJ IDEA to launch using JDK 1.7*, then the variable defined by the TEI is no longer "red". However, being run under JDK 1.7 is not supported by IDEA, apparently.
Final Edit:
I have determined the cause of the problem, as it affects me (OS X):
This is an interaction between IntelliJ running under JRE 1.6 and the project being compiled by a JDK1.7 compiler. My project is all 1.7.
The project is built using the 1.7 compiler. IDEA, running under JRE 1.6 tries to link to the TEI classes inside the project output directory. Since the TEI classes were built with 1.7, they have a class version higher than JRE 1.6 can load, the link fails and the TEI does not get executed.
My workaround is to isolate my Tag and TEI classes to its their own module, set that module to JDK 1.6 (and language level 6.0), then rebuild the project. Now, IntelliJ running under JRE 1.6 can link to the TEI classes, which are now built with JDK 1.6.
Message was edited by: Chris Thielen
Thanks mate!
After firing up Idea13 with JVMVersion 1.7* in Info.plist sorts the issue!
Actually that's fine for me since the project was also for 1.7 so everything works like a charm for now...
Anyway, the issue is a bit weird methinks :-)
Cheers