good afternoon every body, I'm stucked on the following problem...
I have to use jsf and cdi on a project, I've seen that when i use cdi i should be usign the @named instead of @ManagedBean, but when i change it the message is no longer shown on the browser.
it is just a test for now, so it has no complex code and stuff.
here is my index:
<!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://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Hello JSF!</title>
</h:head>
<h:body>
<h:outputText value="#{teste.message}" />
</h:body>
</html>
here is my bean:
package jsfConnection;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
@Named("teste")
@RequestScoped
public class Teste {
public String getMessage() {
return "ola";
}
}
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"
id="WebApp_ID" version="3.0">
<description>Patrimônio web.xml</description>
<!-- Nome da sua aplicação -->
<display-name>Patrimônio</display-name>
<!-- Faces Servlet -->
<!-- Configuração do arquivo inicial quando a aplicação for inicializada -->
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<!-- Configuração do Controlador Faces Servlet -->
<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>*.xhtml</url-pattern>
</servlet-mapping>
when i use @ManagedBean it shows normally but when i switch to @Named it simply does not print anything...