简体   繁体   中英

tag library descriptor in XHTML

Hi i am creating a JSF project, but the autocompletion is not working in eclipse. For example

<?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 lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="/WEB-INF/jsf_core.tld"
    xmlns:h="http://java.sun.com/jsf/html">

<h:head>
    <title>JSF 2.0 Hello World</title>
    <h:outputStylesheet library="css" name="default.css" />
</h:head>
<h:body>
    <h3>JSF 2.0 Hello World Example - hello.xhtml</h3>
    <h:form>
        <h:inputText value="#{helloBean.name}"></h:inputText>
        <h:commandButton value="Click" action="welcome"></h:commandButton>
    </h:form>
       </h:body>
</html>

the tlds are imported by mens of link. when i am pressing ctrl+space afiter f: it is not showing the available commands. so i tried to place the actual file in WEB-INF folder , and import it in the file. Still it is not working.

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="/WEB-INF/jsf_core.tld"
    xmlns:h="/WEB-INF/jsf_core.tld">

Can anybodt help how to do this.

First of all, you should absolutely not extract the loose TLD file from the JAR and dump them in your webapp. This is recipe for portability trouble. Remove them and undo everything else related to this. You should just have those XML namespaces:

xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"

As to the concrete problem of autocomplete not working in Eclipse; the behavior is dependent on the Eclipse version and project configuration used. You need to have at least Eclipse Indigo SR1 in order to have proper builtin JSF 2.0 Facelets autocomplete support. Further the project needs to be created as a Dynamic Web Project with the JSF 2.0 Facet enabled.

Alternatives are integrating the Glassfish Eclipse plugin , or JBoss Tools Eclipse plugin . Particularly the JBoss Tools plugin offers a lot of other awesomeness such as EL expression autocompletion and Ctrl+Click navigation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM