Question

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?

Était-ce utile?

La solution

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.

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top