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.
Related
I try to switch form the Eclipse IDE to Visual Code IDE. I need to work on JSF files and I wonder how vscode can support code completion in this file types?
I expected this to work out of the box, e.g. with a file content like this:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
template="/layout/template.xhtml">
<ui:define name="content">
....
</ui:define>
</ui:composition>
But this does not work. Is there a way I can 'learn' vscode the Jakarta EE xml namespaces? Or adding the tag libraries?
I am trying to use the jsf 2.2 passthrough namespace to pass through certain html5 attributes.
This is what my login.xhtml file looks like:
<!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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
<h:head></h:head>
h:body>
<h:form>
<h:inputText id="name" a:placeholder="name"></h:inputText>
<h:inputSecret id="password" a:placeholder="password"></h:inputSecret>
</h:form>
</h:body>
</html>
Unfortunately, when editing with the web page editor eclipse is giving me an error in this line
xmlns:a="http://xmlns.jcp.org/jsf/passthrough"
The Error says:
NLS missing message: CANNOT_FIND_FACELET_TAGLIB in:
org.eclipse.jst.jsf.core.validation.internal.facelet.messages
I can just ignore that error and the page renders just fine when I deploy the project to glassfish, the placeholder works as expected.
But after that the error disappears (i.e. the line is not yellow anymore) and everytime eclipse tries to validate the file it says:
An internal error occurred during: "Processing variables in index.xhtml".
java.lang.AssertionError
I have spend hours of googling now and found that there were problems in the early beginnings of jsf 2.2.
I am using the latest versions of the jdk, glassfish and eclipse. I downloaded and reinstalled literally all of it tonight and I still can't fix this. I know that I could ignore it since it's working but I wanna know if I am making a mistake or if it's an eclipse bug.
Thanks in advance for your help guys.
try to use my uploaded JSF frontend project, which is fully configured under JSF2.2 and it will solve your problems. it is a maven project, you can deploy it with eclipse or netbeans, my suggest use NetBeans JSF2.2 frontend
I'm new to JSF so maybe it's a noob question.
In eclipse, I create a new JSF project.
After that, I open facex-config.xml, right click -> new view. Here, for every template I choose (html, xhtml, xhtml with xml syntax), eclipse always create a .jsp file.
Now if I try to use JSF 2 tags (like h:link or h:head or h:ajax, jBoss throw errors (and eclipse too)
I solved changing the extension to .xhtml and rewriting the header of the file like this:
<html lang="en" xmlns:f="...." xmlns:h="...">
And with this, all works fine.
The question is: how to create this xhtml file from eclipse instead of manually write it? Isn't JBOSS dev studio supposed to help me? :)
ps:
eclipse: juno
jboss dev studio 6.0
jboss as 7.1.1 final
EDIT:
When the file is created from JBOSS dev studio (xhtml template) this is the result (test.jsp):
<?xml version="1.0" encoding="UTF-8" ?>
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<f:view>
<h:link>test</h:link>
</f:view>
</body>
</html>
I have to rename to .xhtml and remove the lines before !DOCTYPE[...] to get it working.
I'm asking what am I doing wrong with JBOSS dev studio...
Thanks.
D.
i think you should first install JBoss tools to be able to use JSF in your project Install Jboss Tools in Eclipse
then from your eclipse create new web project and from configuration choose Java server faces v2 Project.
I added JBoss tools to my project in an attempt to add some JSF 2 bean aware content completion. I'm really happy with how that's going. I'm using Eclipse for Java EE Juno service release 1 Build id: 20120920-0800. I have the CDI, dynamic web module, Java, javascript, JSF 2.1, JAX-RS 1.1 JBoss Maven Integration 1.0 and JPA 2.0 facets installed on this project.
But now when I use ctrl-i in Eclipse to "align" everything properly my .xhtml files collapse the first layer of tags beneath the tag. I really don't like how it looks, and I don't think it will be standard if other people join the project. Here's what it does.
<?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">
<head>
<title>Login Error</title>
</head>
<body>
<h2>Invalid user name or password.</h2>
<p>Please enter a user name or password that is authorized to access this
application. For this application, this means a user that has been
created in the <code>file</code> realm and has been assigned to the
<em>group</em> of <code>TutorialUser</code>.</p>
<p>Return to login page</p>
</body>
</html>
becomes the below chunk after I use ctrl-i
<?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">
<head>
<title>Login Error</title>
</head>
<body>
<h2>Invalid user name or password.</h2>
<p>
Please enter a user name or password that is authorized to access this
application. For this application, this means a user that has been
created in the
<code>file</code>
realm and has been assigned to the <em>group</em> of
<code>TutorialUser</code>
.
</p>
<p>
Return to login page
</p>
</body>
</html>
Notice how and tags are both lacking a level of indentation. Any ideas on how to fix this or where to configure it would be appreciated.
I downloaded tomcat, eclipse, Struts framework. Tomcat is working. Where to place eclipse and Struts? I placed eclipse and Struts outside tomcat folder. The needed jar files are stored inside eclipse current folder. I'm getting error.
<%#taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
</head>
<body>
<bean:write name="helloWorldForm" property="message"/>
</body>
</html>
unknown tag:bean.write
Eclipse is an IDE. It's used to develop Java applications. Not just one application, but several ones. You shouldn't place any app-specific jar into the eclipse folder.
Struts (and not strut or struct) is a web framework. Its jars must be put in the WEB-INF/lib folder of your deployed application. In an Eclipse web project, the location for them is (typically) <yourProjectDirectory>/WebContent/WEB-INF/lib.