I tried to create a test project for JSF (Primefaces), but it does not work. The test view does not call the managed bean.
This is the managed bean:
package it.myPrimefacesTest.controller;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ViewScoped
@ManagedBean(name="helloWorld", eager=true)
public class HelloWorld implements Serializable {
private static final long serialVersionUID = 7184399511928573344L;
@SuppressWarnings("static-method")
public String getMessage() {
return "Hello World!";
}
}
This is test.xhtml:
<!DOCTYPE html>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
contentType="text/html"
>
<html>
<h:head></h:head>
<body>
ciao!
<h:inputText></h:inputText>
<h:outputText value="#{helloWorld.getMessage()}"></h:outputText>
</body>
</html>
</f:view>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>MyPrimefacesTest</display-name>
<servlet>
<servlet-name>MyPrimefacesTest</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyPrimefacesTest</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyPrimefacesTest</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>true</param-value>
</context-param>
<welcome-file-list>
<welcome-file>test.xhtml</welcome-file>
</welcome-file-list>
</web-app>
faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1"
>
</faces-config>
<h:outputText value="#{helloWorld.getMessage()}"></h:outputText> in test.xhtml does not work.
I'm using:
Java7EclipseJBoss7.1.1
This is because my project was created in this way, and I want to be 1:1.
This is the project: https://ufile.io/ihd8j37g . You have to click on Free Download and then on Slow Speed.