Re: Url PrettyFaces not Initializes @ PreDestroy JSF 2

Splash Forums PrettyFaces Users Url PrettyFaces not Initializes @ PreDestroy JSF 2 Re: Url PrettyFaces not Initializes @ PreDestroy JSF 2

#23116

Your code is a bit confusing. I don’t get what you are trying to do here. You have a mapping for /login that invokes a method that logs the user out.

And could you please the code where you placed the @PreDestroy?

I’m also not really sure if it makes sense to call pretty:user-test in the menu item. If you invoke loginMB.doLogout directly, you browser will send a postback, call the logout code and then redirect to the login page. But if you have pretty:user-test in your action attribute, you will get a postback, then a redirect to the login page which invokes the logout method and then redirects to the login page again. That doesn’t make sense to me. :)

In my applications I typically have two distinct mappings for login and logout. Something like this:

<url-mapping id="login">
<pattern value="/login" />
<view-id value="/pages/login.jsf" />
</url-mapping>

<url-mapping id="logout">
<pattern value="/logout" />
<action onPostback="false">#{logoutBean.logout}</action>
<view-id value="/pages/something.jsf" /> <!-- doesn't matter, because we will redirect anyway -->
</url-mapping>

public class LogoutBean {

public String logout() {
// TODO: process logout
return "pretty:login";
}

}

Please not that the view Id for the logout mapping actually isn’t important, because request to /logout will always be redirected by the action method.