title: PrimeFaces CommandButton: Dynamically enable/disable icon
body: <p>PrimeFaces's CommandButton allows to specify an icon:</p>
  
  <pre><code>&lt;p:commandButton value="Press me" icon="redBall" ... /&gt;
  </code></pre>
  
  <p>However, I need to enable/disable the icon depending on a JSF managed bean property.</p>
  
  <p>I tried</p>
  
  <pre><code>&lt;p:commandButton value="Press me" icon="#{bean.iconClass}" ... /&gt;
  </code></pre>
  
  <p>This works for choosing different icons, but does not allow to disable the icon altogether (i.e. get the same rendering like without the <code>icon=</code> attribute). I can return an empty string in <code>getIconClass()</code>, but PrimeFaces will still render the extra <code>&lt;span&gt;</code> for the icon inside the button, and CSS styling causes this span to be visible with a default icon.</p>
  
  <p>Is there a way to tell PrimeFaces "I want no icon at all" (other than taking out the <code>icon=</code> attribute altogether)?</p>