• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InputRichText - how to get selected text?

 
Petr Dusek
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with ice:inputRichText. I would like to get the selected text - this relates to the client side, I mean - manipulate it on the server side and put it back to the editor (on the same place, as the selected). Could you advice me please some best practise - how to work with this JSF component?

Thanks a lot.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18282
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF is based on the concept of Inversion of Control. In IoC, you don't "get" things, the things are delivered to you.

Thus, if you used the value= attribute to bind a backing bean property to the inputRichText control, the value stored in the client-side text control will automatically be injected into that property when the form that contains it is submitted. The form's action method can then use the data in any way it wishes, including modifying the data so that when the updated form is displayed, the modifications will be sent back to the client.
 
Petr Dusek
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. That is right, bud what about selected text? I agree - I have got an ice:inputRichText and I will write some text. Then I will select a piece of it and do some action with it. But I have the whole text in value attribute, have not I? Could you show me any example, please?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18282
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked at the javadocs and it does not appear that that information is captured.

What you will need to do is add some pre-submit javascript to get the selection information from the CKEditor control and save it in hidden form fields. Then when you process the submitted form, you will have property values that show what you discovered.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic