Hello,
maybe you could add a style tag to your outputText and bind the value to a
field in your managed bean. Inside their you could then give back a value
according your date
if ( date > shouldbe )
return "color:red";
else
return "color:green";
Am Mittwoch, 21. September 2005 18:11 schrieb Christian:
> Hello everyone,
>
> I just tried to do conditional table highlighting in <h:dataTable> or
> <f:dataTable> for a single cell content, without getting a general
> approach of how to do it. You might help me.
>
> Idea:
> I want to implement an eyecatcher. Just imagine MS Excel-table cells. In
> Excel you can define formating rules for cells. Example: If the amout of
> money is negative, it is to be displayed in red, else it is to be
> displayed in black. In my app I want to do this with a date field, ie.
> if the date displayed is lower than the date of today (Usecase:
> "Something is overdue"), it is to be displayed in red instead of black
> as usual.
>
> Situation:
> My <dataTable> is bound to a managed bean containing a list of
> dataBeans, works fine.
>
> #
>
> Things I tried to do:
>
> I tried to do component binding to an HtmlOutputText-Component like
>
> | <x:dataTable var="list"
> | [...]
> | <h:column>
> | <h:outputText binding="#{list.dateOutputCompontent}"
>
> value="#{list.dateOfReturn}"/>
>
> | </h:column>
> | [...]
>
> I also tried to do something like:
> | FacesContext context = FacesContext.getCurrentInstance();
> | HtmlOutputText dateOutput = null;
> | dateOutput =
> | (HtmlOutputText)context.getViewRoot().findComponent("dueD");
> | dateOutput.setStyle("color:red");
>
> in combination with
>
> | <h:column>
> | <h:outputText id="dueD" value="#{list.dateOfReturn}"/>
> | </h:column>
>
> I put the java-code inside the getter of the date value, which did not
> work. The table-display-result broke at the rendering of the first
> date-format.
>
> Question:
> Does anyone have an idea of what to do an where to do.
>
> Thanks in advance.
> Regards
> Christian