0

Im developing a primefaces application and i want to change the style of a row in my datatable, depending of a column value. I managed to do it when some other column is equal to a specific value or text, but what if i want to do it when the value "contains" some text?

When a column value equals "Inactive", it applies the style "red", wich sets the whole column background to red, as follows:

<p:dataTable ... rowStyleClass="#{bean.state eq 'Inactive' ? 'red': null}">

and it also works if i just want to change css style in a <p:outputLabel> like:

<p:outputLabel ... styleClass="#{bean.name eq null ? 'newtext' : null}">

So im trying to change the style when some column value contains a text... is this posible? for example rowStyleClass="#{bean.name contains 'sometext' ? 'somestyle': null}"

Should i do it with java instead?

Kukeltje
  • 12,085
  • 4
  • 21
  • 46
  • 2
    Possible duplicate of [String contains method in jsf](https://stackoverflow.com/questions/13681831/string-contains-method-in-jsf) – Kukeltje Feb 02 '19 at 07:32
  • Please learn the names of the technology you use. This is an EL, Expression Language question – Kukeltje Feb 02 '19 at 07:33
  • and how come you'd think thus is styleClass specific? Always try to find the generic questuion behind your question – Kukeltje Feb 02 '19 at 07:46
  • It would feel better to have this kind of logic in your model and use semantic class names. – Jasper de Vries Feb 03 '19 at 09:46

0 Answers0