Display login user profile data

Asked

Viewed 385 times

0

Good guys to creating a panel where have my profile section for the Administrator who is online can see your profile information. However I am still having problems creating the profile page, I have read some tutorials and watched some video lessons, but it is still dark.

I wanted to know how to display on a page the information of a single user of the database, and in the database there are other users as well.

I know select everything and display all registered users in the bank on a page, but I really wanted to display the user information that be logged in, IE, only his.

I use one to redirect but I have no idea how to call a method that returns me data.

  • If you can already select all users registered in the database, I can’t see a reason not to be able to search a particular user using the login as a parameter of your query

  • because it is! the question is that my named query that I do to catch the user does not return the data

  • @Namedquery(name="User.findByid", query="select u from User u " + "Where u.login = :login")

  • DAO public Usuario buscarUsuairoPorLogin(String login) {
 EntityManager em = EntityManagerUtil.getEM();
 try{
 System.out.println("Login: " + login);
 return (Usuario) em.createNamedQuery("Usuario.findByid")
 .setParameter("login", login)
 .getSingleResult();
 }catch (NoResultException nre){
 return null;
 }
 }

  • bean public String dadosUsuarioCadastrado() {
 UsuarioDAO usuarioDAO = new UsuarioDAO();
 this.visualizaDadosUsuario = usuarioDAO.buscarUsuairoPorLogin(visualizaDadosUsuario.getLogin());
 return "/usuario/usuario_dadosCadastrais.xhtml";
 
}

  • Include your classes in the question itself, so it’s easier for someone to help you with the problem in question

  • can solve. It was only the eclipse that was bugged. It was enough to restart it...vlw

  • Beauty, take advantage and edit your question, the correct is Porém todavia contudo entretanto

Show 3 more comments
No answers

Browser other questions tagged

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