If your list of select items really should be constructed for every
reequest, there's no reason to put it in a session scoped bean -- but
it in a request scoped bean instead (either a common one for shared
items lists, or a page-specific one if it's unique.

To avoid constructing the list multiple times, even if the getter is
called more than once (it will get called once per value binding
expression that points at it), use a common Java idiom in the request
scoped backing bean:

    private SelectItem items[] = null;

    public SelectItem[] getItems() {
        if (items == null) {
            items = ...; // Fill up the list
        }
        return items;
    }

Craig


On 6/14/05, Kris Verhoye <[EMAIL PROTECTED]> wrote:
> Hi again!
> 
> I've been reading through the lifecycle theory again and am confused about
> the way getters and setters are handled:
> 
> How comes that a backing bean getter/setter may be called more than once
> during the lifecycle, and how does one initialize a list of selectItems
> stored in a session scoped bean that should be refreshed every request?
> 
> If I perform the construction of the list in a getter, it would be executed
> more than once. I can't do it in the constructor however as the bean is not
> constructed every request...
> 
> Cheers,
> Kris
> 
> 
> 
>

Reply via email to