users@javaserverfaces.java.net

Re: Initialise Backing Bean from database

From: Roger Kitain <Roger.Kitain_at_Sun.COM>
Date: Thu, 26 Apr 2007 13:51:54 -0400

ChrisC wrote:

>Hi
>
>I need to initialise a backing bean with values from a db table - I know the
>username of my logged in user from:
>
>FacesContext facesContext = FacesContext.getCurrentInstance();
>String owner = facesContext.getExternalContext().getRemoteUser();
>
>I want to set the user details on the bean - name, address - so that when
>you go to the account details page the values for the logged in user are
>displayed.
>
>i.e. What I want is an initialisation method - so that when the bean is
>created it gets the values it needs using the username and sets the other
>properties.
>
>As I understand it Backing Beans do not have a constructor - so how I get it
>to go off and set the values.
>
>
Why do you say backing beans (managed beans) do not have a constructor?
They are just POJO's, and you should be able to do the initialization.

>Many thanks
>
>Chris
>
>
>
>