-
1. Re: Performance issue getter method?
mail.micke Jun 24, 2008 5:27 PM (in response to prasad_k)Hi there
Did you read my reply to your previous question?
-
2. Re: Performance issue getter method?
diegocoronel Jun 24, 2008 7:59 PM (in response to prasad_k)Did you tried a factory ?
-
3. Re: Performance issue getter method?
prasad_k Jun 25, 2008 7:52 AM (in response to prasad_k)Hello Mikael Andersson ,
thank you for hint,
i read your reply but i not getting the solutions for this, i tried but list not update when any when any event has done.
please suggest me any other reason. why getter method is calling many times.
thanks -
4. Re: Performance issue getter method?
mail.micke Jun 25, 2008 9:30 AM (in response to prasad_k)Hi
You shouldn't put any expensive (datbase lookups for example) in getter methods!
Instead you can move the loading of the data into a @Create or @Factory annotated method, that will ensure that the data is loaded once.
In your earlier post you had a @Create annotated method which did the data initialization, BUT you also called the same method from your get method which you shouldn't.If you werent using seam, then you would have to do something like this (don't do this unless you have to):
public List<String> getFooList(){ if(fooList == null ){ fooList = do.getFooList(); } return fooList; }
In that way you cache the fooList for the later invocations of the get method.
Hope this helps a little,
micke