0

I am new to JSF and started learning and have worked on struts. Just wanted to understand how navigation works in JSF2.0. I understand in JSF2.0 navigation rules can be done in faces-config.xml. But I would like to understand how it works in real world.

Suppose I have a screen to enter search criteria and the next screen should dispaly the search results.Where do I process the result set <h:commandButton value="Show Results" action="#{simpleController.doNavigation}"/>and my doNavigation() does the job of querying the database and fetch the results, how do I carry it next screen. Do I need to hold the value in SESSION

Sazzadur Rahaman
  • 6,938
  • 1
  • 30
  • 52
user2462959
  • 75
  • 11

1 Answers1

0

Just assign the data as a property of the current bean instance.

public String doNavigation() {
    results = searchService.find(query);
    return "nextpage";
}

By default, navigation doesn't fire a new request, it just sets the target page to the current response. In the target page, you can just use #{simpleController.results}.


Unrelated to the concrete problem, this is a poor practice (bad for SEO and UX). Rather show the results in the very same page and don't perform navigation on postbacks.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555