Colegas, boa noite.
pesquisei, e ate achei topicos relacionados, mas nao resolveu.
Estou estudando e minha pagina index.xhtml, não esta exibindo o resultado que passei no metodo, ou seja, ela abre, mostra a mensagem de boas vidas da da tag
do html, mas nao o resultado da variavel no metodo.
Estou usando o javax.faces-2.2.7.jar.
Pagina index.xhtml
<!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></h:head>
<body>
<h1> Bem vindo a pagina index.xhtml</h1>
<h:outputLabel value="#{controlerPrincipal.mensagem}" />
</body>
</html>
Aqui minha classe com ManagedBean
package br.com.controller;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name = "controlerPrincipal")
@RequestScoped
public class ControlerPrincipal implements Serializable{
private static final long serialVersionUID = 1L;
private String mensagem;
public ControlerPrincipal() {
SimpleDateFormat sdf =
new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:S");;
mensagem = "Criado no momento +"
+ sdf.format(Calendar.getInstance().getTime());
System.out.println(mensagem);
}
public String getMensagem() {
return mensagem;
}
public void setMensagem(String mensagem) {
this.mensagem = mensagem;
}
}
Aqui meu arquivo web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
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-app_3_0.xsd">
<display-name>FirstWebJSF</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<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>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Ao exibir ou abrir o arquivo index.xhtml era pra exibir a mensagem da variavel abaixo:
mensagem = "Criado no momento +"
+ sdf.format(Calendar.getInstance().getTime());
Nota: Estou usando o TOMCAT 7 e o JSF2.0
Poderiam me ajudar por favor?