Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sendRedirect not working  RSS feed

pradeep chellappan
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am having a facelet say main.xhml, that has 4 tabs on it. The contents of each tab is inturn a facelet which has corresponding backing bean. I am making a webservice call in the backing bean corresponding to 2nd tab and the code is inside a try catch block. If there is an issue with the webservice call, then we catch the exception and below is the code in Catch block:

response.sendRedirect(req.getContextPath() + "/techError.xhtml");

It is redirecting to techError, but it is getting displayed in tab-2 with tab-2 open. When i see the address bar, the url is corresonding to "req.getContextPath() / main.xhtml". I am not getting any exception related to redirection in console either.

Actually, i want to display the techerror page in full screen.

The same approach works fine for tab-1. When some exception happens for tab-1 backing bean, it redirects to techError page and i can see only techError page in full screen, i don't see any tabs.

In Faces- config i have a navigation -rule as below:


Please let me know if you need futher details for directing me.


Tim Holloway
Posts: 18720
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd go with a pop-up modal dialog (NOT a pop-up window) for an error display on a tabbed page. That way I could keep my tabs underneath. Second prize would go to a JavaScript pop-up messagebox, for the same reason (though less customizable).

However, you need to learn the difference between a RESOURCE path and a [b/]URL[/b] path. JSF navigation is done based on URLs, not on resources, although you can use navigation rule IDs as an abbreviated basis for URLs in JSF2. In short, "/mypage.xhtml" is wrong. That's the resource name. "/mypage.jsf" is the URL name.

The other thing I'll fault is using brute force for page navigation. If you code a proper action processor, you can simply return the value "error" and standard navigation will route you to the error page. The #1 error that people make when using JSF is to gratuitously over-complicate things that were designed to be simple.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!