Managed Beans

Hello,

Are there any best practices for using Managed Beans?

How to make managed beans thread-safe for concurrent requests,
without compromising on efficiency/speed?

2. How to enforce the J2EE security with managed-beans?

3. How to decide the scope of these beans to ensure minimal data-storage
in session?

4. How to decide the granularity at which a managed-bean should be used
for example :

4.1 One bean-per-component
4.2 One bean-per-form
4.3 One bean-per-page

Also i would like to know how to design managed beans from reusability perspective.

Regards,
Smita

Managed Beans

Hi smitad,

There are three managed-bean-scope.
1. Application :
The data is shared among all requests and all sessions

2. Session :
It will be terminated if the web application invokes the invalidate method on the HttpSession object or when it times out.

3. Request :
It is used when you wanted to forward the object to another processing phase inside the current request. And after that destroy the object.

You should decide yourself, which one is the best to use for specific action.

For me myself, I will not create a bean for each component. It is possible to have more than one bean. But I will not divide it based on the component. I will divide it based on the controller logical point of view.

It is better to design the application with MVC concept. I will have one or more bean as my controller logic and also model classes.

I have not answered all the questions you addressed in this post. But I hope it helps

Andys