Currently I have four pages that are each backed by their own RequestScoped managed bean. An example of this would be the following...
backing search.xhtml
@RequestScoped
SearchBean
backing result.xhtml
@RequestScoped
ResultBean
backing detail.xhtml
@RequestScoped
DetailBean
backing action.xhtml
@RequestScoped
ActionBean
In each page (except for the search page), I inject the bean from the previous page to access the input parameters. For instance...
@RequestScoped
public class Result {
@ManagedProperty("#{search}")
private Search search;
private ResultData resultData;
private Service service;
public Result() {
}
@PostConstruct
public void init() {
resultData = service.getResultData(search);
}
// getters & setters
}
@RequestScoped
public class Detail {
@ManagedProperty("#{result}")
private Result result;
private DetailData detailData;
private Service service;
public Detail() {
}
@PostConstruct
public void init() {
detailData = service.getDetailData(result);
}
// getters & setters
}
@RequestScoped
public class Action {
@ManagedProperty("#{detail}")
private Detail detail;
private ActionData actionData;
private Service service;
public Action() {
}
@PostConstruct
public void init() {
actionData = service.getActionData(detail);
}
// getters & setters
}
I want to use redirect so that I am able to use the back button, but while doing so I lose the input data from the managed bean in the request. I could use SessionScope for each bean, but I feel like I would be abusing it. Also, I am worried about the overhead by the time I get to the action page. At this point, since each bean injects the previous bean, all four ManagedBeans are created when the page is triggered. Is there a better way of doing this than using RequestScoped beans. I suppose I could have one SessionScoped bean for the series of pages and use it to carry input parameters across requests. This would also allow me to use the redirect feature and wouldn't load all four managed beans when the action page is finally hit. Any suggestions would be appreciated. Thanks.