简体   繁体   中英

How many views should a backing bean belong to?

I just read through this question: JSF backing bean structure (best practices) and I am trying to understand when I should make a new backing bean in my application. If I have a view with registering a question should I then have a backing bean for that task, and another one backing bean for the editing of a question, and a third one for the view where I list all the questions and so on? Or, should these three views have a common backing bean?

And if I have a view and a backing bean for adding a question on the admin side, can I use the same backing bean for adding a question on the user side which has its own view since they both will do the same task?

Recognize that you can have combinations of extension and composition. I always try to have one backing bean per page. If there are common elements on multiple pages, I'd factor those out into a common utility bean - and then have that utility bean as a member of the backing beans for each page that needs it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM