• Post Reply Bookmark Topic Watch Topic
  • New Topic

url filter problem  RSS feed

 
nkarthi123
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i work with following code but error can occur.so please help me step-by-step process for this by using visual jsf in netbeans 6.1


public class LoggedOnPhaseListener implements PhaseListener {

private static final long serialVersionUID = 7805022367671101424L;
private static final Log logger = LogFactory.getLog(LoggedOnPhaseListener.class);

public LoggedOnPhaseListener() {
logger.info("LoggedOnPhaseListener created");
}

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

@Override
public void beforePhase(PhaseEvent ev) {

boolean expire = false;
FacesContext facesContext = ev.getFacesContext();

// We going to the logon page or the expire page
boolean loginPage = facesContext.getViewRoot().getViewId().lastIndexOf("login") > -1 ? true : false;
boolean forgottenPasswordPage = facesContext.getViewRoot().getViewId().lastIndexOf("forgottenPassword") > -1 ? true : false;
boolean forgottenUsernamePage = facesContext.getViewRoot().getViewId().lastIndexOf("forgottenUsername") > -1 ? true : false;
boolean adminReactivationPage = facesContext.getViewRoot().getViewId().lastIndexOf("adminReactivation") > -1 ? true : false;
boolean expirePage = facesContext.getViewRoot().getViewId().lastIndexOf("sessionExpire") > -1 ? true : false;

if (!loginPage && !expirePage && !forgottenPasswordPage && !forgottenUsernamePage && !adminReactivationPage && !loggedIn(facesContext)) {
expire = true;
}

if (expire) {
logger.info("user session is not valid... logging out");
facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, "sessionExpired");
}

}

@Override
public void afterPhase(PhaseEvent ev) {
}

private boolean loggedIn(FacesContext facesContext) {
boolean result = true;
Map<String, Object> smap = facesContext.getExternalContext().getSessionMap();
if (smap.containsKey("loggedOnDetails")) {
LoggedOnDetails details = (LoggedOnDetails) smap.get("loggedOnDetails");
if (details.getUserDTO() == null) {
result = false;
}
} else {
result = false;
}
return result;
}
}
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!