phaselistener

Invalidating session with CDI+JSF not working

末鹿安然 提交于 2020-02-03 09:21:15
问题 I'm trying to implement a logout in my application, so I made this: public String logout(){ try{ FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext ex = facesContext .getExternalContext(); ex.invalidateSession(); return "success"; }catch(Exception e){ return "error"; } } But when I check if the user is logged, it says yes: public class AuthenticateListener implements PhaseListener { @Override public void afterPhase(PhaseEvent event) { AuthorizedUser authorized =

Logging the invoked managed bean action in a PhaseListener

泄露秘密 提交于 2019-12-30 07:01:05
问题 I am using Sun JSF 2.0 and wrote a phase listener extending javax.faces.event.PhaseListener . I am able to log source URI, target URI, total time and so on. But so far unable to log the ManagedBean and corresponding method that would be invoked during that client event. How can I do this? 回答1: Input components send their client ID as request parameter name in case of synchronous requests and as request parameter value of javax.faces.source request parameter in case of asynchronous (ajax)

Logging the invoked managed bean action in a PhaseListener

岁酱吖の 提交于 2019-12-30 07:01:04
问题 I am using Sun JSF 2.0 and wrote a phase listener extending javax.faces.event.PhaseListener . I am able to log source URI, target URI, total time and so on. But so far unable to log the ManagedBean and corresponding method that would be invoked during that client event. How can I do this? 回答1: Input components send their client ID as request parameter name in case of synchronous requests and as request parameter value of javax.faces.source request parameter in case of asynchronous (ajax)

How to @Inject in a PhaseListener

雨燕双飞 提交于 2019-12-18 04:08:34
问题 I have added a PhaseListener to faces-config.xml : <lifecycle> <phase-listener>com.project.NotificationListener</phase-listener> </lifecycle> The class seems to be otherwise correct as it is pretty simple. public class NotificationListener implements PhaseListener { @Inject private MyCDIStuff stuff; @Override public PhaseId getPhaseId() { return PhaseId.RENDER_RESPONSE; } @Override public void beforePhase(PhaseEvent event) { this.stuff.doStuff(); } } The 'beforePhase' method gets called

How to retrieve a session scoped managed bean in a PhaseListener?

血红的双手。 提交于 2019-12-11 07:35:29
问题 I'm having troubles in setting an Authorization Listener (that implements PhaseListener) to manage authentication and autorization. More specifically, I set a session scoped bean called SessionBean: @ManagedBean @SessionScoped public class SessionBean{ private String loggedUser; public SessionBean(){ logger.info("Sono nel costruttore di SessionBean()"); } public String login(){ .... } ... } And in my sun-web.xml: <managed-bean> <managed-bean-name>SessionBean</managed-bean-name> <managed-bean

JSF 2: Change rendered atribute of a component on phase listener

给你一囗甜甜゛ 提交于 2019-12-11 06:24:41
问题 Hy guys, In JSF 2 How can I change the rendered atribute of a h:InputText component using a PhaseListener. Before the jsf page be rendered I have to verify all id of the h:inputtexts, and after that I will change the atribute to be rendered or not. Am I clear? 回答1: On GET requests, the view root is not created yet during the before phase of the render response and during the after phase it's too late because the response is already been rendered and sent to the client. The view root is

How to apply a JSF2 phaselistener after viewroot gets built?

岁酱吖の 提交于 2019-12-07 03:50:44
问题 In my JSF2 application I have a phaselistener that needs to be executed before RENDER_RESPONSE but after JSF has built the viewroot. First, what I did is register my PhaseListener in faces-config. The listener then gets called, but when I perform the beforePhase, getViewRoot().getChildren() is still empty. Secondly, I found how to do this by adding the following on my xhtml pages: <f:phaseListener type="be.application.PolicyController" /> This works fine, but adding this to each of my pages

How to apply a JSF2 phaselistener after viewroot gets built?

丶灬走出姿态 提交于 2019-12-05 07:18:15
In my JSF2 application I have a phaselistener that needs to be executed before RENDER_RESPONSE but after JSF has built the viewroot. First, what I did is register my PhaseListener in faces-config. The listener then gets called, but when I perform the beforePhase, getViewRoot().getChildren() is still empty. Secondly, I found how to do this by adding the following on my xhtml pages: <f:phaseListener type="be.application.PolicyController" /> This works fine, but adding this to each of my pages would be extremely tedious. Hence I'm looking for a possibility to do this once for my application. Any

Limitations of using a PhaseListener instead of a Servlet Filter for authorization

蹲街弑〆低调 提交于 2019-12-01 22:08:07
问题 I'm currently using a PhaseListener as below to perform user authorization. private PhaseId phaseId = PhaseId.RESTORE_VIEW; @Override public void afterPhase(PhaseEvent event) { FacesContext fc = event.getFacesContext(); boolean isOnAllowedPage = false; String[] allowedPages = choseRightPages(); // chose pages for role for (String s : allowedPages) { if (fc.getViewRoot().getViewId().lastIndexOf(s) > -1) { isOnAllowedPage = true; break; } } if (!isOnAllowedPage) { NavigationHandler nh = fc

Limitations of using a PhaseListener instead of a Servlet Filter for authorization

落花浮王杯 提交于 2019-12-01 21:47:25
I'm currently using a PhaseListener as below to perform user authorization. private PhaseId phaseId = PhaseId.RESTORE_VIEW; @Override public void afterPhase(PhaseEvent event) { FacesContext fc = event.getFacesContext(); boolean isOnAllowedPage = false; String[] allowedPages = choseRightPages(); // chose pages for role for (String s : allowedPages) { if (fc.getViewRoot().getViewId().lastIndexOf(s) > -1) { isOnAllowedPage = true; break; } } if (!isOnAllowedPage) { NavigationHandler nh = fc.getApplication().getNavigationHandler(); nh.handleNavigation(fc, null, "prohibited"); } } It does what I