Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Joe Ess
  • salvin francis

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

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

Posts: 3648
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simplest is to use a style class (css) to change the font color.
Saloon Keeper
Posts: 21422
Android Eclipse IDE Tomcat Server Redhat Java 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.
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!