1

I made a from with input text area, and the value will come from database. value is some thing like : A 2 year notice has bean applied by mycompany with effect from 12 December 2012. I want to hilight 12 December 2012 with some different background color.

Note: value will come dinamycally from database.

<h:inputTextarea cols="60" rows="5" id="messageId" style="margin-top:3px;"
    value="#{messageBean.textMessage}" />

How can i do this? Thanks !!

Naveen A
  • 533
  • 4
  • 8
  • 16

2 Answers2

2

Since <h:inputTextarea generates <textarea

Its impossible

Take a look at this similar questions:

Change the Color Of Certain Words In Textarea using Jquery?

And

color codes in textarea using jquery

You can use some WYSIWYG text editor

Like this one used in Primefaes Editor

Or just integrate some third party js WYSIWYG text editor , like CKEditor or TinyMCE


You also can strip all the toolbars/buttons from the editor , so it will eventually look like almost like a textarea

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200
0

No it is impossible. But you can do a trick.
You can make your <h:inputTextarea component transparent by using the css property background:transparent;. Then use another colored div and place it behind the word you want to highlight. Sometimes you may need to add display:inline-block; to your highlighter div if JSF doesn't render the div with the width you give. A negative z-index may also be needed.

prageeth
  • 7,159
  • 7
  • 44
  • 72