0

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();
}
Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
Fabii
  • 3,820
  • 14
  • 51
  • 92
  • 1
    Any reason you're using `immediate` here? Have you tried without it? Also check if specifying the full `action="#{billingController.invalidateSession()}` makes a difference. And just checking the obvious, you've put a breakpoint in there and observed it never getting hit so you can assert "is never called"? – mabi Jan 29 '14 at 07:46
  • @mabi removing immediate="true" did it. Post your comment as an answer so I can accept it. – Fabii Jan 30 '14 at 15:59

2 Answers2

1

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.

Community
  • 1
  • 1
mabi
  • 5,279
  • 2
  • 43
  • 78
0

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.

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40