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.

3
  • 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? Commented Nov 23, 2017 at 14:30
  • If you like to logout a jsf session. Listen to BalusC himself. See the light:stackoverflow.com/questions/5619827/… and this is also a good example stackoverflow.com/questions/2499317/… if you want it in javascript. Please explain why it is needed first Commented Nov 23, 2017 at 15:03
  • 1
    #{request.userPrincipal != null} is only evaluated when your page is rendered, not each time your timer fires. Commented Nov 23, 2017 at 15:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.