There is a managed bean(DemoManagedBean.java) which holds some data on the (sample.xhtml)XHTML page.
There is a redirection link in the sample.xhtml which opens a new tab of the same page(sample.xhtml) but with different data loaded.
Issue - since there is only one instance of the DemoManagedBean.java, therefore not able to process anything further i.e; changes on one tab affect all the other tabs.
Is there a way so that I can have a multiple instances for every tab holding the data for the particular tabs?
Thanks,
Dinesh
You control that by setting the right bean scope. In your particular case, you need to put the bean in the request scope or in the view scope, depending on if you need a per-view based state or not.
Using the standard JSF bean management API, that would be just this (no XML needed!):
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class DemoManagedBean {
// ...
}
When the @XxxScoped
scope annotation is not specified, it defaults to @NoneScope
. Your description however matches the session or application scope. Perhaps you've explicitly set the @SessionScoped
or @ApplicationScoped
annotation while not really understanding what you were actually doing. Or perhaps you're for some reason using Spring to manage beans, a Spring @Controller
without any explicit scope specified defaults to application scope.