user378101
user378101

Reputation: 669

Problem with JSF form submit

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.

Upvotes: 0

Views: 754

Answers (1)

Bozho
Bozho

Reputation: 597076

  • don't use redirect, use forward (in your navigation case)
  • if using JSF 2.0, use @ViewScope
  • check MyFaces Orchestra
  • try <a4j:keepAlive> from richfaces

Upvotes: 1

Related Questions