Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Highlighting Words in JSF components  RSS feed

 
Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Just wondering if the following is possible..

When I submit my record to be saved.. I check for certain 'badwords'/expletives in some of the fields. If any are found I would love to be able to highlight those words... However I'm using SelectInputText components.. So I dont think thats possible...

Secondly I have a datatable with a Lucene based search facility which populates the table depending on the search.. Again I would love to be able to highlight the search term(s) in the table of results... I imagine this would be more possible as it presents its data using OutputText components...

Any thoughts appreciated.

Thanks
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a client side language like Javascript.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The inputText JSF tag renders as an HTML INPUT TYPE=TEXT control, so you're out of luck there, since that control lacks fine-grained formatting features. You'd have to replace it with a smarter input text control than the standard JSF one.

outputText is much easier. Just format the property string using HTML markup and use the escape="false" attribute on the outputText element.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
 
Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:The inputText JSF tag renders as an HTML INPUT TYPE=TEXT control, so you're out of luck there, since that control lacks fine-grained formatting features. You'd have to replace it with a smarter input text control than the standard JSF one.

outputText is much easier. Just format the property string using HTML markup and use the escape="false" attribute on the outputText element.


Ahh okay thanks.. so in the case of my table.. would this be a worthy approach : User enters search term and clicks search button... I add the search phrase to session, then after applying a special Converter to each column in the table, I could pick up the search term from the session in the converter getAsString() method and look for and apply html to the found text there..

As for the InputText boxes.. Best I can do there is just apply a 'message' to the relevant box indicating that a badword was found...

Thanks for the input..
 
Sir General
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using Javascript would be efficient and the best solution.

I had implemented lucene search in my app. Though I just highlight the search text when a hit or a search result is selected.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!