title: How to pass backing bean value to JavaScript?
body: <p>I would like to read the backing bean value in JSF and then pass over to JavaScript, may I know how this can be done?</p>
  
  <p>Backing bean sample code:</p>
  
  <pre><code>@ManagedBean(name="enquiry")
  @SessionScoped
  public class Enquiry {
  
    public boolean noQuery;
  
    /** getter and setter **/
  }
  </code></pre>
  
  <p>In XHTML sample code, I would like pass the backing bean value and then pass into <code>showNoQueryPrompt()</code> like this:</p>
  
  <pre><code>&lt;h:commandLink onClick="showNoQueryPrompt(#{enquiry.noQuery})"&gt;
  &lt;/h:commandLink&gt;
  </code></pre>
  
  <p>And then in JavaScript code, I can read the boolean value to determine whether I should prompt or not prompt. Here is the code:</p>
  
  <pre><code>&lt;script ...&gt;
     var showNoQueryPrompt(Boolean showPrompt) {
  
       if( showPrompt == "true" ) {
          alert('No query');
       }
     }
  &lt;/script&gt;
  </code></pre>