0

I am trying to learn the basic of Java Server Faces (JSF) and currently I am facing problem that the entered content in the input field in the hello-world.xhtml is not being rendered in the myresponse.xhtml file. Does someone see the error for this behaviour?

hello-world.xhtml

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:a="http://xmlns.jcp.org/jsf/passthrough">

    <h:head>
        <title>Hello World - Input Form</title>
    </h:head>
    <h:body>

        <h:form>
            <h:inputText id="name" value="#{theUserName}" 
                            a:placeholder="What's your name?" />

            <h:commandButton value="Submit" action="myresponse" />
        </h:form>

    </h:body>
</html>

myresponse.xhtml

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html">

    <h:head>
        <title>Hello World - Response</title>
    </h:head>
    <h:body>

        Hello, #{theUserName}

    </h:body>
</html>

screen shoot

enter image description here

Edit:

So I tried it in the Version: Mars.2 Release (4.5.2) with Tomacat 7 and Java 8 and it did not work but when I tried it with Version: Kepler Service Release 2 with Tomcat 7 and Java 8, it worked.

C:\Windows\System32>java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)

Is there any explaniation for that?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Mr Asker
  • 2,300
  • 11
  • 31
  • 56
  • which tutorial did you follow? Defining Project Facets does not mean the relevant libraries are also included. The facets you refer to are 'specs' and you still need to include the libraries. Either for just compiling or also runtime. Since Tomcat already includes the relevant 'dynamic web module' libraries and you obviously have 'java', that is all there. The jsf libraries are not, at least not for tomcat. Using Mars or Kepler does not make a difference afaics. Maybe Kepler was already correctly configured before – Kukeltje Jun 19 '16 at 17:33
  • @Kukeltje: I follow this tutorial: https://www.youtube.com/watch?v=PH8AxwGRYjM&index=10&list=PLEAQNNR8IlB5H6fbgvNl_oN259gdZAnXl – Mr Asker Jun 19 '16 at 17:36
  • So you missed 2:25? Downloading jsf library etc... – Kukeltje Jun 19 '16 at 17:53
  • I have clicked it and downloaded the jsf 2.2 Mojaar library as in the tutorial already before. – Mr Asker Jun 19 '16 at 18:05
  • Project's `/WEB-INF/lib` folder is empty (while it is not a Maven project). This is not right. Tomcat doesn't ship with JSF out the box. It's expected that the webapp has JSF libraries in `/WEB-INF/lib` folder. Furthermore the JSF servlet should be explicitly mapped on `*.xhtml` and URL in browser's address bar must match JSF servlet mapping. This is all already detailed in the abovelinked duplicate. – BalusC Jun 20 '16 at 07:53

0 Answers0