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.
>
If you're using JSF 1.2, you can annotate an initialization method with
the @PostConstuct annotation.
The method annotated as such will be called after the bean is created,
but before it is put into service.
On the flip side, you can also annotate a method with @PreDestroy to
release any resources that the
bean may be using.
> As I understand it Backing Beans do not have a constructor - so how I get it
> to go off and set the values.
>
> Many thanks
>
> Chris
>
>
>