title: Confirmation dialog with dynamic message content for h:commandButton
body: <p>I am trying to create a confirmation dialog for a commandButton in JSF. The message I want to display is "Are you sure you want to deploy to #{deployBean.environmentName}?", where            #{deployBean.environmentName} refers to the selected value of h:selectOneMenu.</p>
  
  <p>I used plain JavaScript in the 'onClick' parameter of h:commandButton to do this. The XHTML code is as follows:</p>
  
  <pre><code>&lt;h:commandButton id="deploy" 
  value="Deploy" 
  action="#{deployBean.deployButtonAction}" 
  disabled="#{(!deployBean.checkDeploy and (deployBean.stageComplete or deployBean.stageRunning)) or (deployBean.stageStart)}" 
  onclick="return confirm('Are you sure you want to deploy to #{deployBean.environmentName}?');" &gt; 
      &lt;f:ajax event="keyup" render="status output detail"/&gt;
  &lt;/h:commandButton&gt;
  </code></pre>
  
  <p>But the environment name does not get displayed in the confirmation dialog box.</p>
  
  <p><img src="https://i.stack.imgur.com/yj5Jk.png" alt="Output of the code"></p>
  
  <p>Please let me know what I'm missing in my code. Or please let me know if there is a better way to do this.</p>