Craig, regarding your first statement about making the bean a request scope vs session...
Maybe I put too much into one backing bean (one backing bean runs multiple related screens) but in my case I need some values (say properties) to remain at session scope and others to be at request scope. This makes Galen's approach with AspectJ appealing, but it would be even better if I could specify right on the property that the getter method should only be called once. I have read most of the JSF spec and at the time had a 1,000 ft understanding of why the getters weren't guaranteed to be called only once, but I would still like to see something implemented into the spec that allows the bypassing of a secondary call rather than implementing an "if(property==null)" type approach. I guess the question in my head is how would one elegantly code a property to execute its code only once in a bean that is session scoped? Because the below example will only work the first time the session bean is invoked, but the second visit to the page it will already be full (with old information). It would be cool to have a destroy() or destructor method for each backing bean for clean up purposes. I have pseudo implemented this with a method in my code called "cleanupConstructor()", but I ran into problems with my ORM solution's values getting waxed before data was persisted to the database (design flaw on my end). Aaron Bartell http://mowyourlawn.com -----Original Message----- From: Craig McClanahan [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 14, 2005 11:14 AM To: MyFaces Discussion; [EMAIL PROTECTED] Subject: Re: getter/setter, lifecycle 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 > > > >

