3

I am using JSF 2.0. I don't want to call setter & getter multiple time. Can you help me to avoid that?

1 Answers1

4

Why is that bothering you? Those calls are extremely cheap.

Perhaps you're incorrectly invoking expensive business logic in getters/setters instead of in (post)constructor and/or action(listener) methods? That's indeed a very common starter's mistake in JSF. Just don't invoke business logic in getters/setters. Invoke business logic in (post)constructor and/or action(listener) methods instead. Getter/setters are purely meant to get and set the (already-prepared) bean properties.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Then remove the loggers from those methods to prevent you from an undeserved heart attack. Just keep them pure and ignore them further. Hide them in the far bottom of the class. They're merely used to access/change bean properties. – BalusC Oct 05 '12 at 14:13
  • Yea, You are correct. my getters/setters are only to set & get values. My all business logic are in –  Oct 05 '12 at 14:22