Вопрос

I'm working on a PhaseListener which runs before RESTORE_VIEW and I need to know whether it runs for the first time in the current session or not (so that I can do some auto-login for stay-logged-in-users).

Any hints for me?

Это было полезно?

Решение

Yes, you can do such a thing. I have a same phase listener:

@Override
public PhaseId getPhaseId() {
    return PhaseId.RESTORE_VIEW;
}

@Override
public void beforePhase(PhaseEvent event) {
    FacesContext ctx = FacesContext.getCurrentInstance();
    if (!ctx.isPostback()) {
    authRet = // check for active session
    if (!authRet) {
         if (...)// check for cookies { //create auth}
         else { // redirect to login }
    }
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top