0

I have some code, and I don't know why he nor work, when I want call logoutAction() managed bean function.

<script type="text/javascript">
    const sessionTimeOut = #{timeoutBean.getTimeout()};
    function startTimer(timeoutCount = 0) {
      if (#{request.userPrincipal != null}) {
        if (timeoutCount >= sessionTimeOut) {
            logoutAction();
        }
        setTimeout(startTimer, 1000, timeoutCount + 1);
      }
    }
  </script>

and my form

<h:form>
    <p:remoteCommand name="logoutAction" actionListener="#{logoutBean.logoutProcess}"/>
  </h:form>

Help me please.

noxi
  • 99
  • 7
  • I don't know JSF at all, but are you not mixing front-end and back-end code? Like, expecting JS in the browser to launch a function that exists on the server? – Jeremy Thille Nov 23 '17 at 14:30
  • If you like to logout a jsf session. Listen to BalusC himself. See the light:https://stackoverflow.com/questions/5619827/how-to-invalidate-session-in-jsf-2-0 and this is also a good example https://stackoverflow.com/questions/2499317/how-to-implement-logout-process-in-jsf-application if you want it in javascript. Please explain why it is needed first – pwain Nov 23 '17 at 15:03
  • 1
    `#{request.userPrincipal != null}` is only evaluated when your page is rendered, not each time your timer fires. – Jasper de Vries Nov 23 '17 at 15:30

0 Answers0