Question

I created a method in the bean

public void checkSessionLife() {
        if (FacesContext.getCurrentInstance().getExternalContext().getSession(false)==null) {
            System.out.println("*\n");
            System.out.println("destroyed");
            FacesContext.getCurrentInstance().addMessage("sessiongr", new FacesMessage(FacesMessage.SEVERITY_INFO, "erer", "errrrrrrrrr"));
            RequestContext requestContext = RequestContext.getCurrentInstance();
            requestContext.update(Arrays.asList("hreaderForm:sessiongr"));
        }
    }

and in my PgTemlate.xhtml i add a <p:poll> to update a <p:growl>

<p:poll interval="5" listener="#{accessBean.checkSessionLife()}" process="@this" global="false"/>
                <p:growl id="sessiongr" showDetail="true" sticky="true"/>

the problem is that the activity is seen as <p:poll> activity sessions There he has another method to notify the user?

Was it helpful?

Solution

What is the scope of accessBean? If it's anything less than application scope, I believe the function will fail to run, because JSF cannot find the bean.

Nonetheless, this isn't the recommended method for handling session expirations. For the preferred one, see BalusC's method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top