JSP tag code completion in xhtml files

I was hoping it would just work in 8.x. This is my first attempt at creating JSF files in Intellij so I'm not sure what I need to do. I can't get code completion working for any JSF tags in XHTML. I haven't tried JSPX yet but I suspect the results might be better.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xml:lang="en" lang="en">
<head>
    <title></title>
</head>
<body>

</body>
</html>

0
9 comments
Avatar
Mariusz Nosinski

I'm developing IceFaces web application based on .xhtml files and don't have any problem with code completion.
Maybe you didn't change file type recognition? Go to Setting -> File types and move *.xhtml file pattern from 'Xhtml files' group to "JSPX Files" group.

0

What do you try to complete? Does resolve work for you?


0

I'm trying to complete tags from the core and html tag libraries. It works fine when I keep the JSF tags in JSP pages. Even if I remap the xhtml extension to the JSPx file type, I get an error in the editor telling me the URI for the tag library is not registered. I expected the IDE to pick up the TLD in the jar file but no go so far. I'm running build 9880 on Kubuntu 9.04 with JDK 1.6.0_13. I have the same issue with build 9852.

Grant

0

The latest build, 9886, fixed the code completion problem I observed. I can no longer reproduce it from a simple test project I created or the more complex project where I first experienced it.

Grant

0

I wish somebody could explain exactly what is necessary to get code completion of JSF tags working consistently. It works in a newly created xhtml file but not in the JSP page. This is getting frustrating to say the least. If I try to refactor my JSP page to an XHTML file it still does not work. The behavior is simply inconsistent in my environment.

This code works (code completion for all tags)...


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xml:lang="en" lang="en">
<head>
    <title></title>
</head>
<body>
</body>
</html>

This code does not work in my JSP page...
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="ui" uri="http://java.sun.com/jsf/facelets" %>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>

0

Doesn't Facelets is different from jsps? And given that facelets
specific tlds are not meant to be used in jsps.

Grant Lewis wrote:

I wish somebody could explain exactly what is necessary to get code completion of JSF tags working consistently. It works in a newly created xhtml file but not in the JSP page. This is getting frustrating to say the least. If I try to refactor my JSP page to an XHTML file it still does not work. The
behavior is simply inconsistent in my environment.

This code works (code completion for all tags)...


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
</body>
</html>

This code does not work in my JSP page...
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="ui" uri="http://java.sun.com/jsf/facelets" %>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>

---
Original message URL: http://www.jetbrains.net/devnet/message/5240419#5240419



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

I'm not sure I agree that facelets tags don't work in JSP pages. I can't speak to the facelet TLD files. I went JSP instead of XHTML because of the issues I observed in 8.1.2. When I upgraded to 8.1.3 code completion in XHTML files started working so I'm happy to replace JSP with XHTML. What I really want is an official response that no, facelets code completion does not work in JSP, but does work in XHTML files, so I can properly configure my project. I went ahead and replaced my JSP pages with equivalent XHTML files.

0
Avatar
Mariusz Nosinski

Facelets works with files that are XHTML compilant.
You can't use: <%@ taglib uri="http://java.sun.com/jsf/html prefix="h" %>
You need to use xml sytax in this place :
<html xmlns="http://www.w3.org/1999/xhtml xmlns:h="http://java.sun.com/jsf/html" >
addictionally Facelets needs to use .xhtml file extension.

0

Actually, <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %> works fine from a JSP. Sorry, I'm a stickler for details. What doesn't work is <%@ taglib prefix="ui" uri="http://java.sun.com/jsf/facelets %>. It's also not accurate to say facelets need a .xhtml extension. That simply isn't the case since the extension can be controlled with a context parameter in the web.xml file. Sure, it requires well formed XML, but that's about it. I mapped several different extensions and they all worked. The Intellij editor complained but not Tomcat or the facelets framework.

From my experience, Intellij wants the file extension on the facelets files to be .xhtml and the .xhtml extension mapped to the JSPx file type. It may be non-standard but I really expected the editor to work with an XML or XHTML file. The syntax in the file is equivalent and the editor did hiccup a little bit. It flagged errors that were not errors in the XML file although code completion did work in both files, XML and XHTML.

Here is my web.xml file that worked with an XML extension...

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xml</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>test_viewer.faces</welcome-file>
    </welcome-file-list>
     <listener>
         <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
     </listener>
</web-app>

Grant

0

Please sign in to leave a comment.