webtier@glassfish.java.net

Re: _at_PreDestroy on a ViewScoped managed bean

From: <webtier_at_javadesktop.org>
Date: Wed, 07 Oct 2009 09:41:14 PDT

The following code is working fine for me:


import java.io.Serializable;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped
public class ViewWatcher implements Serializable {

    long serialVersionUID = 0L;
    volatile Logger log = Logger.getLogger("viewwatcher");
    String hello = "Hello";

    @PostConstruct
    public void init() {
    log.severe("starting view");
    }
    
    @PreDestroy
    public void finish() {
    log.severe("finishing view");
    }
    
}

With a series of pages that include #{viewWatcher.hello}

So - what ever is going on in your code, @PreDestroy is being called at the right time.
[Message sent by forum member 'driscoll' (jim.driscoll_at_sun.com)]

http://forums.java.net/jive/thread.jspa?messageID=367148