File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Getter called too many times Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Getter called too many times" Watch "Getter called too many times" New topic

Getter called too many times

Vadim Vararu
Ranch Hand

Joined: Jan 03, 2009
Posts: 147
I have a getter method:

I'm debugging the moment when this page loads and i don't know why getDataList method is called more than 10 times.... I can't understand where it is called from. I don't have this method call in other places in the page.

If you think you've done too much, usually it means you've done too few.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Well, your first mistake is in using JSTL on a JSF view. That almost always means you're not using JSF effectively, and in many cases, you can actually interfere with the proper operation of JSF.

Your second mistake was in not understanding the JSF lifecycle. It's quite normal for getters to get called multiple times on a view request. The main concern there is that the getter be exactly that: a method to get a value. If you try and throw additional logic into the get method, you'll see unfortunate side-effects.

An IDE is no substitute for an Intelligent Developer.
Vadim Vararu
Ranch Hand

Joined: Jan 03, 2009
Posts: 147
Ok, i know that during the lifecycle it calls getter more than one time, but not more than 10 times...
I agree. Here's the link:
subject: Getter called too many times
It's not a secret anymore!