File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 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:
subject: Conditional formatting text
It's not a secret anymore!