Question

I call the client side function like so : invalidateUserSession(). I know the client function is triggered because I placed an alert in the oncomplete event. For some reason the server side method is never called though.

Client side code:

<a4j:jsFunction 
    name="invalidateUserSession"
    action="#{billingController.invalidateSession}"
    immediate="true"
    oncomplete="alert('invalidate');"
/>

Server side code:

public void invalidateSession(){
     log.info("Invalidation session...");
     FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
}
Was it helpful?

Solution

As per the comments, just remove the immediate=true from the tag.

Obligatory link: Debugging JSF lifecycle

Also note that you are still displaying the user's data and might want to redirect/re-get the page after a session invalidation.

OTHER TIPS

Your action should return Object, for example String. See action attribute descption in VDL documentation:

MethodExpression representing the application action to invoke when this component is activated by the user. The expression must evaluate to a public method that takes no parameters, and returns an Object (the toString() of which is called to derive the logical outcome) which is passed to the NavigationHandler for this application.

Simple change void to String in method signature.

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