• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need to show text or word in a different color in <h:inputText>  RSS feed

 
Nandakumar Perumal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my application we are using Code - Description format in Inputtext. Customer getting confused to differentiate which is Code and which is Description. So they asked us to differentiate those things like using different colors.

In h:outputText we have attribute called escape="false" to use html tags in the value of outputText.

But in the h:inputText we do not have any attribute like escape="false" to use html tags inside of inputText.

So Please can anyone help me out of this issue that how to show a code and description with different colors in the inputtext of JSF or Primefaces component.

Thanks in advance..

Thanks and Regards,
Nandakumar Perumal.

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simplest is to use a style class (css) to change the font color.
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSF inputText control is a wrapper around the raw HTML INPUT TYPE=TEXT control.

You can change the background color of the text input field. You can change the foreground color of the text itself. You do this using CSS.

What you CANNOT do is make just one word of the text have a different style from all the other words. That's because if HTML cannot do it, then JSF cannot do it.

There is a way to allow input in a multiplicity of colors, fonts, weights, and text styles but that required some sort of "rich text input" control. These controls are enhancements to the HTML TEXTAREA control with client-side JavaScript support (often using pre-built frameworks such as TinyMCE.

In fact, the JavaRanch message editor is such a control, although it's not JSF-based.

Both RichFaces and PrimeFaces provide JSF-based rich input controls. I'm sure other eJSF xtensions do as well, although I don't have a definitive list.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!