• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conditional formatting text

 
Chris Grimble
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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}" />
</font>

(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
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic