1 Reply Latest reply on Aug 2, 2007 12:49 AM by Gavin King

    Check if conversations are active before session invalidatio

    Andrea Newbie

      I implemented a very simple script to call a logout action:

       <!-- 10 minutes timeout -->
       <script type="text/javascript" language="JavaScript"><!--
       setTimeout('Redirect()', 600000);
       function Redirect() {
       // --></script>
       <h:form id="tor_form">
       <t:commandButton id="tor_button" style="display:none;" value="redirect" action="#{logout.logout}"/>

      The logout action invalidates the session and redirects to the login page:

       // Before invalidating the whole session check if other conversations
       // are running
       if(!ConversationsAgent.getInstance().activeConversationsExist()) {
       return "login";
       // Otherwise leave session open and just redirect to home
       else {
       FacesMessages.instance().add("No activity timeout occurred.");
       return "home";

      I added the if/else conditions because if I invalidate the session all active conversations (in other tabs) will be destroyed and this is not what I want. I implemented the activeConversationsExist() as it follows:

       public boolean activeConversationsExist() {
       for (ConversationEntry entry : ConversationEntries.instance().getConversationEntries()) {
       return true;
       return false;

      which is not good because it checks the whole conversation stack (including other connected clients or browsers) and not the ones related to the session I want to invalidate.

      So, my question is: is there a way to check if only the session-related conversations are ended?

      Thanx, cheers!