0
Good morning, I am the following problem. I have an application that has several Managedbeans that are working normally. Today I went to create a new bean to do a test and this bean does not run nor the @Postconstruct and no other method; I created a new project, copied the bean and xhtml and the new project worked, but I wouldn’t want to recreate it all again. or still, I 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 the test 2.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:
- In a new project works normal.
- I’m using Eclipse Mars 2 and Tomcat 8
- Versions are:
- javax.faces(Mojarra) = 2.2.8-02
- javax.Servlet-api = 3.1.0
- primefaces = 5.3
- primefaces-Extensions = 3.2.0
Questions
1 - It is normal from time to time to have to create a new project ?
2 - Why this happens ?