public class MyBackingBean{
private List model;
public String search(){
//change model data
model = doSearch();
return "same_view"
}
@PostConstruct
public void init(){
model = loadDefault()
}
//Other code omitted for clarity
}
And in JSP, for some reasons I use c:foreach to iterate over the model and display the items in a HTML table. The jsp page has got a searh button the action of which is mapped to the #{mybackingbean.search}. So when i click seach, i expect only a subset to be displayed(based on search params) on the same page. The problem i have is that, "When i click on search button,search method is getting invoked and it returns a view name. Since the bean is request scoped, a new instance of the bean is getting created after this and eventually the init method overwrites the results.Meaning, i get the same initial view which displays all the items instead of displaying only the matching items".
What is wrong with this ? And please guide me on the ideal approach to solve this.