I have a jsf page that perform three actions. Is it better, in term of design, to have one separate bean for any action or a single bean with all actions?

有帮助吗?

解决方案

It really depends on the functional requirements, but generally you use one request/view scoped bean per <h:form>.

So, if all actions are in such way related to each other that they really belong in the same form, then just put them in the same bean. If those actions are however completely unrelated to each other (e.g. login form, contact form, language selection form), and thus sit each in its own <h:form>, then they should each refer their own bean.

其他提示

In term of design: It is better to have one Bean with the view. As JSF is MVC,

In term of performance: better performance will be achieved by linking each view with one bean, but in case your view has heavy actions (like 2 tables "master detail"), so it is better to have bean for each action.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top