0

I'm 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", which 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 I'm trying to change the style when some column value contains a text... is this possible? for example rowStyleClass="#{bean.name contains 'sometext' ? 'somestyle': null}"

Should I do it with java instead?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • 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