JSF calling setter & getter multiple times

老子叫甜甜 提交于 2019-12-31 02:19:07

问题


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


回答1:


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:

  • Why JSF calls getters multiple times


来源:https://stackoverflow.com/questions/12740842/jsf-calling-setter-getter-multiple-times

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!