I have multiple live charts. Currently I have multiple links one for each chart. When a user clicks a link, the corresponding chart is loaded and every 5 seconds an ajax call is made to invoke the action method in the viewscoped managedbean. When the user clicks another link, previous setinterval is cleared and the same process is repeated for another chart. For all these charts (links), their corresponding action methods are in the same viewscoped managedbean which is backed by one EJB, with one service method corresponding to each action method.
So far so good.
The next step is to have a link to display all those live charts simultaneously on the view. Now, I know that there are going to be multiple asynchronous ajax calls. I believe that the servlet (FacesServlet) handles all these requests in a separate thread. But what happens with the managedbean and the ejb. Do I need to create separate managedbeans (if the MB is RequestScoped then does JSF create a separate instance for multiple asynchronous ajax requests) and separate ejbs? I am kind of confused right now and need some helpful advice. I want them to be processed concurrently.
Thank you.
Update:
First of all thanks to bogdan.mustiata.
Now, since I am not getting any more answers I will try to make little bit clearer.
What I am really trying to understand is:
When I have a ViewScoped (or a SessionScoped) managed-bean and a Stateless EJB -
- How is a request handled on the server side?
- How are multiple aynchromous Ajax requests handled on the server side?
Following is my understanding -
- Request is sent to the server.
-
FacesServlet starts a thread per request.
-
Within that thread -
- Managd-bean action method is executed.
- An instance of EJB is provided by the container and corresponding method in the EJB is executed.
So that way multiple Ajax requests are handled simultaneously.
Is that how it is?