• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sendRedirect not working

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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:


<navigation-rule>
<navigation-case>
<from-outcome>error</from-outcome>
<to-view-id>/techError.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

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

Thanks.


 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic