jQuery in Action, 3rd edition
The moose likes JSF and the fly likes Conditional formatting text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Conditional formatting text" Watch "Conditional formatting text" New topic

Conditional formatting text

Chris Grimble

Joined: Jan 19, 2005
Posts: 3
I have a page produced by JSF which displays a current price and the amount it has changed during the day. This value is got from a managed bean with

<h utputText value="#{values.price}" /> <h utputText value="#{values.priceChange}" />

I can set the colour to red by doing.

<font color=red>
<h utputText value="#{values.price}" /> <h utputText value="#{values.priceChange}" />

(I know I could do this with css but eventually intend for this to run on a browser that doesn't support css)

How do I alter the colour of the text produced so that it is red if the price change is less than 0, blue if it is more than 0 and green if it is 0?
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Extend com.sun.faces.renderkit.html_basic.TextRenderer.java class and render the text/font/etc. the way you want

P.S. You will have access to the component's value hence you can change it at run-time.
[ February 17, 2005: Message edited by: K Varun ]

- Varun
I agree. Here's the link: http://aspose.com/file-tools
subject: Conditional formatting text
It's not a secret anymore!