Good morning, I'm the following problem. I have an application that has several ManagedBeans that are working normally. Today I was creating a new bean for testing and this bean does not execute either @PostConstruct or any other method; I created a new project, copied the bean and xhtml and the new project worked, but I would not want to recreate everything again. or would like to know what happened.
Follow the bean:
package teste;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean(name = "testeBean2")
@ViewScoped
public class TesteBean2 implements Serializable {
private static final long serialVersionUID = 1L;
@PostConstruct
public void init() {
System.out.println("aqui estou dentro do bean ");
}
public String getMensagem() {
System.out.println("chegou aqui ");
return "bada bada";
}
}
Follow test2.xhtml:
<!DOCTYPE html>
<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"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
<h:head>
</h:head>
<h:body>
<h:form>
<h:outputText value="aqui #{testeBean2.mensagem}" />
</h:form>
</h:body>
</html>
Important:
- javax.faces (Mojarra) = 2.2.8-02
- javax.servlet-api = 3.1.0
- primefaces = 5.3
- primefaces-extensions = 3.2.0
Questions 1 - Is it normal from time to time to have to create a new project? 2 - Why does this occur?