How to stop reload the data from db for every request?

Your bean is declared with request scope. That means, it gets created new for each request. Quite apart from that: if(this.

Service == null) will always be true because the setter gets called only once when the bean is created (no matter what scope it has).

Your bean is declared with request scope. That means, it gets created new for each request. Quite apart from that: if(this.

Service == null) will always be true because the setter gets called only once when the bean is created (no matter what scope it has). If you're sure the data will never change between requests, simply declare the bean with session scope, and it will be created once per user session, or application scope to have it created once for the entire application.

Thank you. But it is working, but it does't load from db upto logout. For example If I go back to screen, I want to load again from DB.

If I clink any button in same screen then don't reload from db. – venkat Feb 4 at 10:32 @venkat: in that case, you'd want the view scope introducted in JSF 2. But be aware that this means your bean's contents will be serialized and saved as hidden parameters in the page itself.

This can cause quite a few problems. The alternative is to use session scope but find a way to detect on-page navigation and don't reload the data only in that case. – Michael Borgwardt Feb 4 at 10:39 Saved as hidden parameter is only true when state saving is set to client instead of (default) server.

And this does not apply to view scoped beans specifically. – BalusC Feb 4 at 12:44 @BalusC: Hm, I'm not setting explicitly anywhere, and I get Exceptions when the bean is not Serializable (and this does not happen with session and application scoped beans). I'm using MyFaces.

– Michael Borgwardt Feb 4 at 12:52 View scoped beans are stored in component tree which in turn get serialized in session. The only hidden parameter is javax.faces. ViewState which is basically the session attribute key of the component tree.

– BalusC Feb 4 at 12:57.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions