0

我仍然是 JSF 编程的初学者,我正在尝试做一个小例子来了解它是如何工作的。我面临的问题是从未调用托管 bean 的 @PostConstruct 方法(其中的实例从未进行过,并且其中的 println 没有显示任何内容)我尝试了各种托管 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);
}
4

1 回答 1

0

感谢您的意见。我刚刚发现我的项目缺少什么:它是 jboss-deployment-structure.xml !我将它与依赖项一起添加,它起作用了,虽然我还不明白。

于 2014-07-28T07:45:49.303 回答