0

I have a rich:datatable like so:

<rich:dataTable var="scheduledTimeItem" 
value="#{itineraryBean.weekDaysScheduledTimes}">
    <rich:column style="text-align: center;">
        <h:outputText>#{scheduledTimeItem.formattedStartTime}   </h:outputText>
    </rich:column>
</rich:datatable>

And I would like to, for example, put background-color: red in the style of that row if the value of scheduledTimeItem.formattedStartTime is greater than 17:00h or the current time for example.

How do I send the value of the row or its index to the bean at the time that is rendered?

StudioWorks
  • 455
  • 5
  • 22
  • 2
    Possible duplicate of [How to conditionally style a row in a rich:dataTable](http://stackoverflow.com/questions/963971/how-to-conditionally-style-a-row-in-a-richdatatable) – Kukeltje Jun 02 '16 at 21:23
  • @Kukeltje That just helps to style an entire column – StudioWorks Jun 03 '16 at 13:25
  • @Kukeltje link contains zebra style example and value related row style. Check all answers. Main idea: define styles in css and use its in data table via `rowClasses` attribute. – Vasil Lukach Jun 03 '16 at 15:41
  • I still think @Turo solution is better since I have to check if the date inside formattedStartTime is greater than the current time in my bean to highlight the row or not and with rowclasses I'd have to make this comparison in the EL part of the code like he does in rowClasses="#{myBean.is_validValue == false ? (rowkey mod 2 == 0 ? 'order-table-even-row' : 'order-table-odd-row') : 'found'}" and I don't think it can be done. I'm still testing it though. – StudioWorks Jun 03 '16 at 17:01

1 Answers1

1

You could do something like this

<h:outputText styleClass="#{scheduledTimeItem.style}">#{scheduledTimeItem.formattedStartTime}   </h:outputText>

for every column.

Turo
  • 3,909
  • 2
  • 11
  • 23
  • 1
    Then you basically style the cell content, not the cell. For the cel content to fully encompas the cell you need to play with margins, padding etc. – Kukeltje Jun 02 '16 at 21:21
  • You're right, your link shows in the right direction. – Turo Jun 02 '16 at 22:02