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();
}
有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top