0

I'm still a beginner at JSF programming and I'm trying to do a little example to understand how it works. I'm facing the problem where the @PostConstruct method of a managed bean is never invoked (the instanciations in it are never made, and the println in it doesn't show a thing) I tried all sorts of managed beans (Session, Request...), but there is always the same problem !

My managed bean :

@ManagedBean(name = "helloWorldMBean")
@SessionScoped
public class HelloWorldMBean implements Serializable {

private static final long serialVersionUID = 1L;
private PortletRequest request;
private String nom;
private String prenom;
private String complement;
private BigDecimal age;
private String year;

/* getters and setters */

@PostConstruct
public void init() {
    System.out.println("Hi !");
    if (request == null) {
        request = (PortletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    }
    complement = "...";
    nom = "Init";
    System.out.println("Comp : " + complement);
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Job
  • 1
  • 1
  • I assume you are referencing the bean using EL in a jsf page? – Khary Mendez Jul 25 '14 at 13:40
  • Hi kharyam, yes I use it in a jsf page as follows : – Job Jul 25 '14 at 13:43
  • I do not know anything about portlet, but beside this, I cannot spot any error. What JSF version are you using? what machine is your code running on? what do your imports look like? What does your faces-config look like? How do you try to access the webpage? – stg Jul 25 '14 at 17:19

1 Answers1

0

Thanks for your comments. I just found out what was missing on my project : it's the jboss-deployment-structure.xml ! I added it with the dependencies and it worked, though I don't understand it yet.

Job
  • 1
  • 1