There are several reasons why getters are called more than once, for example, checking for value changes, rendering and etc.
You can try lazy initialization to fetch only once like;
private List clients;
public List getClients() {
if(clients == null)
clients = fetchFromDB();
return clients;
}
First call to the getter will hit the db and set the clients list, other calls will just return the same list and not hit the db.
Cagatay
On 6/1/06, Furer Alexander <[EMAIL PROTECTED]> wrote:
HiWhy getter method of managed bean called few times for particular phase ?I have "clients" (List) property of managed bean, getter method fetchs List from DB, how can i fetch only once ?Below is call trace for it's getter/setter:ThanksBEFORE RESTORE_VIEW(1)
setClients, size: 17
AFTER RESTORE_VIEW(1)
BEFORE APPLY_REQUEST_VALUES(2)
getClients, size: 17
getClients, size: 17
getClients, size: 17
AFTER APPLY_REQUEST_VALUES(2)
BEFORE PROCESS_VALIDATIONS(3)
getClients, size: 17
getClients, size: 17
AFTER PROCESS_VALIDATIONS(3)
BEFORE UPDATE_MODEL_VALUES(4)
getClients, size: 19
getClients, size: 19
AFTER UPDATE_MODEL_VALUES(4)
BEFORE INVOKE_APPLICATION(5)
AFTER INVOKE_APPLICATION(5)
BEFORE RENDER_RESPONSE(6)
getClients, size: 19
getClients, size: 19
getClients, size: 19
getClients, size: 19
getClients, size: 19
getClients, size: 19
getClients, size: 19
AFTER RENDER_RESPONSE(6)

