Well, you said it yourself. You must move the bean from RequestScope
.
Depending on your application, you can use:
@SessionScoped
@ViewScoped
Here you can find an article about choosing the right area.
Secondly, you can use Injection Dependency. JSF has a nice @ManagedProperty
. You can read about it here .
EDIT
Seeing now that you do not want to use the session, another solution that comes to my mind is the following:
@ManagedBean @ViewScoped public class Bean1 implements Constants{ private List<SelectItem> countryList; private List<String> choosenCountryList; private List<String> choosenProgramList; private String invoiceDatePriorTo= CalendarUtilities.getTodaysDate() ; private List<CustomResults> searchResultList public getSearchResults(){
As you said, the problem is that you cannot save all the information from one request to another. This is usually the case when @ApplicationScoped
or @ViewScoped
are commonly used. For various reasons, this may not be the best solution in some cases.
For your example, the best solution would be to place all the methods in one bean, which is @ViewScoped
. This approach has its drawbacks, but I think it is as good as it gets.
Here you can find out more about this.
Ionut source share