0

I want to use JSF for a project (i just started learning), and i startwd with this example

<!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:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

<head>
   <title>JSF Tutorial!</title>
</head>
<body>
   <h2>h:inputText example</h2>
   <hr />
   <h:form>
      <h3>Read-Only input text box</h3>
      <h:inputText value="Hello World!" readonly="true"/>
      <h3>Read-Only input text box</h3>
      <h:inputText value="Hello World"/>
   </h:form>
</body>

</html>

But when i load the page, i can see only texts, the input fields do not appear.i

As a server i use Apache Tomcat 7.0 with Eclipse IDE

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • Lots of questions here: How is your web.xml configured? What is the extension of this file? Have you put all the LIBs on your WEB-INF/libs folder? – Jorge Campos Jan 13 '14 at 11:38
  • I think you should use h:body – Koray Tugay Jan 13 '14 at 11:42
  • this file is an .xhtml file . and my libs folder is empty(shouldn't the ide add the libs when i create the new project? ) web xml looks like this '( TrafficSystem )' – user1833671 Jan 13 '14 at 11:52

1 Answers1

0

Currently your inputText is not interpreted (when you open your webpages source in your browser, you will find the plain h:inputText tag in there).

Make sure, that your web.xml and faces-config.xml are correctly filled. (e.g. your web.xml includes the Faces Servlet, something like ...)

....
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
...

While Application Server like JBoss usually bring Libraries for JSF pre-installed, for the Apache Tomcat Web-Container you have to add the Libraries for JSF - either through manually copying the needed JARs into Tomcats /lib - directory or via configuring your IDE to package them into your projects WAR being delivered to the tomcat (they will be stored in your JARs /WEB-INF/lib directory).

Eclipse WTP e.g. has under right-click "project properties" -> "deployment assembly" an dialog for configuring those.

L-Ray
  • 1,629
  • 1
  • 15
  • 26
  • Why no mapping on `*.xhtml`? – BalusC Jan 15 '14 at 20:30
  • Good question. The current project I copy'n'pasted the code from uses jsf as extension ;-) A mapping to *.xhtml is of course possible, too. – L-Ray Jan 15 '14 at 21:39
  • follow this link http://stackoverflow.com/questions/4441713/migrating-from-jsf-1-2-to-jsf-2-0/21227775#21227775 – Pravin Dec 02 '14 at 14:40