Im trying to use @aroundInvoke in my interceptor, checking some validationX to proceed with the execution of the method or else REDIRECT the user to a specific JSF page.
@AroundInvoke
public Object myInterceptor(InvocationContext invocation) throws Exception {
if(validationX){//it passes the validation so proceed
return invocation.proceed();
}else{//it doesnt passes the validation so go to
//DO SOMETHING TO REDIRECT TO SPECIFIC JSF
}
}
I've tried:
- returning String with "JSF?faces-redirect=true" ----- I get converting error(String to whatever the metod should return).
- FacesContext.getCurrentInstance().getExternalContext().dispatch("/JSF.jsf"); ----- I get nullPointerException with getCurrentInstance method.
- FacesContext.getCurrentInstance().getExternalContext().redirect("/JSF.jsf"); -------The same NullPointerException.
- Using HttpServletRequest and HttpServletResponse to generate a response but I get NullPointer Exception.
Thanks in advance!