title: JSF f:ajax onevent not reading bean value
body: <p>I have an AdminBean that has a loggedIn boolean which is set after a query from an onclick:</p>
  
  <pre><code>    &lt;h:commandButton rendered="#{!adminBean.loggedIn}" styleClass="moreButtonAsText" id="adminLoginAsText" value="Login" action="#{adminBean.logIn}"&gt;
        &lt;f:ajax render="detailsBox adminForm" execute="@form" onevent="onevent"/&gt;
      &lt;/h:commandButton&gt;
  
    &lt;/h:form&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
    function onevent(e){
      if(e.status=='success') {
        alert(#{adminBean.loggedIn});
      } 
      if(e.status=='complete') {
        alert(#{adminBean.loggedIn});
      } 
    }
  &lt;/script&gt;
  </code></pre>
  
  <p>I need this because I want to do a different javascript thing based on if the user successfully logged in or not.  The command button is first clicked (obviously) and then logged in is set to true.  I have this explicitly in my AdminBean class:</p>
  
  <pre><code>public boolean isLoggedIn() {
      System.out.println(loggedIn);
      return loggedIn;
  }
  </code></pre>
  
  <p>Originally I had the onevent all nested like <code>onevent="#{adminBean.loggedIn} ? yesFunction : noFunction</code>, but this did not work.  So I read around and found 
  <a href="http://fyhao.com/2010/05/computer-and-it/java/java-server-faces/jsf-2-fajax-why-execute-onevent-three-times/" rel="nofollow">http://fyhao.com/2010/05/computer-and-it/java/java-server-faces/jsf-2-fajax-why-execute-onevent-three-times/</a>
  So I decided to split it up into an inline function, but this still didn't work.<br>
  Then I decided to go with what I posted above, except with clear alert statements as to what the JavaScript thinks the value is (and my printlines to see if they agree...)</p>
  
  <p>The Java console, by the first alert (which is <code>e.status=='complete'</code>), prints out a lot of falses at first, and then a lot of trues.<br>
  The JavaScript alerts false.</p>
  
  <p>I then clear the console and click ok on the alert.  The console then prints <em>nothing</em>, and the second alert is called, still false.  So my JavaScript fails.  </p>
  
  <p>Now one other weird thing I noticed... the AdminBean is session scoped.  When I press enter in the address bar again, no matter what I do the JavaScript will alert true... even though the renders still work properly (stuff that should only render when logged in is not shown, even though the JavaScript alerts <code>true</code>).</p>
  
  <p>What the heck is going on?</p>
  
  <p>If you need more information/code, ask.</p>
  
  <p><strong>Edit #1:</strong></p>
  
  <p>When I said above that I tried <code>onevent="#{adminBean.loggedIn} ? yesFunction : noFunction</code>,
  I also tried <code>onevent="#{adminBean.loggedIn} ? yesFunction : noFunction</code>.  I realize I may be missing quotes/apostrophes on those functions, but before I solve that issue I'd like to fix the adminBean.loggedIn issue.</p>
  
  <p><strong>Edit #2:</strong></p>
  
  <p>See the selected answer;  I was working on this solution and then the answer basically confirmed my results.</p>
  
  <pre><code>&lt;h:form id="javascriptHack"&gt;
    &lt;h:form id="hiddenJS" rendered="#{adminBean.loggedIn}" &gt;
      &lt;script type="text/javascript"&gt;
        $(function() {
          (#{adminBean.loggedIn}) ? slowCloseAdminPanel() : adminPanelLeftOpen();
        });
      &lt;/script&gt;
    &lt;/h:form&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>This might be a hackish way to do it, but it works.</p>