Is there any way to change styleClass based on condition for primefaces components?
if there is, please suggest me.
I wrote like this..
styleClass="#{(bean.comment==null) ? style1 : style2}"
is it correct way to give value for styleClass?
please suggest me better ways if any.
thank u
You can do this, but it needs little modification. You should return string which represents class name:
styleClass="#{(bean.comment==null) ? 'style1' : 'style2'}"
Another approach is to calculate this condition in backing bean, and use simpler EL:
styleClass="#{bean.style}"
and in backing bean:
public String getStyle() {
return (comment == null) ? "style1" : "style2";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With