This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSF and the fly likes Reinitializing session scoped JSF objects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSF
Bookmark "Reinitializing session scoped JSF objects?" Watch "Reinitializing session scoped JSF objects?" New topic

Reinitializing session scoped JSF objects?

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 395
I have a Java object that has a method called when a application starts up. It has an error handling list that I want to reinitilaize each time the main page is accessed.

The method gets called and then the page is shown. For some reason, if I make the object request scope, the page can't see it. Looks like JSF makes a new request object when you forward a page.

I tried calling session.removeAttribute\Add but it does not work. Any ideas?
[ August 04, 2008: Message edited by: M Burke ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17023

By definition, request-scope objects are created for each HTTP request and destroyed after the request has been processed.

For something that's initialized once and kept for the life of the application (common to all users), put the item under application scope.

I do this for things like drop-down menu lists that come from databases so I don't have to reload from the database every time someone needs it.

Customer surveys are for companies who didn't pay proper attention to begin with.
M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 395
Thanks for the advice, Tim
I agree. Here's the link:
subject: Reinitializing session scoped JSF objects?
It's not a secret anymore!