Problem with Viewscoped Requestscoped and Session

Asked

Viewed 137 times

0

I have the following scenario:

A Datatable with a button that executes a Bean method, but this Datatable is using a Lazy Loading Pagination, but according to the session annotation that I use the button method is not executed or the session is terminated.

If I use the annotation in Bean:

javax.enterprise.context.RequestScoped

The entire search for popular Datatable runs, but the edit button when triggered does not execute the Bean method.

I already use the annotation in Bean:

javax.faces.view.ViewScoped

The search is not performed by complete, but the activation of the edit button executes the Bean method.

I create the Session through a Daofactory

public static DocumentoDAO criarDocumentoDAO() {
   DocumentoDAOHibernate documentoDAO  = new DocumentoDAOHibernate();
   documentoDAO.setSession(HibernateUtil.getSessionFactory().getCurrentSession());
   return documentoDAO;
}

Any suggestions on how to resolve?

  • Does anyone have any suggestions?

1 answer

0

Using @RequestScoped, your data is only visible during the request. For manipulation of tables on a screen, I indicate the @ViewScoped, that will keep your data visible while staying on screen.

Read more about the scope of ManagedBeans here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.