Let's say I have a form with ten input fields, and each of them has AJAX validation. Can I still use a Request scoped backing bean, or should I use View scoped to keep the page performant? Is it too expensive to recreate the backing bean on each validation request, if there are not too many DB queries? Are there any guidelines when to use View scoped bean in a situations like this?
Asked
Active
Viewed 459 times
1
-
Measuring is knowing. Just run a profiler in the target system and compare the results. The one server enviornment certainly can't be compared with another server environment. There are *so many* factors which can have influence on this. Note that this is not JSF-specific. – BalusC Sep 09 '13 at 02:36
-
Possible duplicate of [How to choose the right bean scope?](https://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope) – JonathanDavidArndt Oct 15 '18 at 18:26
1 Answers
0
You should use View scoped beans.
Unless you have a reason to do otherwise, using Request scope will be confusing: page state is not preserved between trips to the server. Using View scope will make your page behave the same way you think about the page: requests go to the server, responses come back, the page saves its state as long as the user does not navigate away from the page.
With 10 input fields, your performance overhead should be negligible. Depending on your application, performance might even improve (!)
As suggested in the comments, if you have serious performance concerns, run a profiler. Convince yourself that what you are doing is correct.
Here are some guidelines on which scope to choose:

JonathanDavidArndt
- 2,518
- 13
- 37
- 49