@ViewScoped creating new instance on every postback
I am having the below managed bean. But every time I do a post back to the same bean ie while calling updateFileList. I get a new instance of FileDAO. How can I prevent this? Is it safe to have a DAO inside a managed bean, if not what changes can I make to better it. @ManagedBean(name = "file") @ViewScoped public class FileController implements Serializable { private static final long serialVersionUID = 1L; private List<LoadFileLog> fileList = null; private Date selectedDate; FileDAO fileDAO; public FileController() { System.out.println(" In file Controller constructor"); ServletContext