Problem with JSF Redirect 2

Asked

Viewed 59 times

0

I have a CDI Session Bean which I store some information for use in the application while the user is logged in, however I need a control that when the other Beans try to use some attribute of this Bean it is Null that the user is redirected to the information selection page.

Made the implementation in the get of the tribute in question and valid if the current page is the page of the selection if it is open the page if it does not redirect. This solution works for some screens for others has error 500 and I know it is not the ideal way to treat this problem.

Any suggestions on how I can do it?

1 answer

0

The Omnifaces has a Feature calling for FullAjaxExceptionHandler, that redirects you to the page you choose if given Exception was created.

Example:

public String getBla() {
    if (bla == null) {
        throw new BlaException();
    }
    return bla;
}

In web.xml:

<error-page>
    <exception-type>br.com.bla.BlaException</exception-type>
    <location>/bla.xhtml</location>
</error-page>

http://showcase.omnifaces.org/exceptionhandlers/FullAjaxExceptionHandler

  • I’ll check and test.

  • I think I’m doing something wrong, but it didn’t work. I implemented as the example document but kept asking to launch Exception and not be able to make it work.

  • In this example spoke the class Blaexception, when I insert it in the get of the attribute it asks to make a Try or cast the exception and does not work.

  • Exact. Or you create the function public String getBla() throws BlaException { or you cause a RuntimeException, thus: throw new RuntimeException(new BlaException());.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.