简体   繁体   中英

JSF 2.0 - change component style

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

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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM