1
votes

I have simple component - CommandButton

   <tr:commandButton text="test" styleClass="form-button"
    actionBean="#{testPage}" action="synchAction" 
    partialSubmit="true" id="btnId" />

This commandButton uses styleClass form-button.

I have in the backing bean some boolean member which changes it's value after some event trigger.

Is it possible to change my commandButton StyleClass according to that boolean ?

I mean , when this boolean become true , the commandButton styleClass will change to some-other-style.

I appreciate any help,

Thanks,

John

1

1 Answers

4
votes

Use an el expression and the ternary operator in your styleClass attribute:

 <tr:commandButton text="test" 
             styleClass="#{bean.boolVal ? 'form-button' : 'another-style'}"
             actionBean="#{testPage}" action="synchAction" 
             partialSubmit="true" id="btnId" />