I am trying to use p:editor to edit text that may contain character entities like < or ®. The problem is that when a string edited by the user in a p:editor is returned to the backing bean, the character entity is replaced by the actual character it represents, plus a garbage character. For example, an original string obtained from a database might be:
Code: Select all
<h1 style="[%h1]">ENERGY STAR<sup>®</sup> Performance Rating<br></h1>
After a simple edit like removing one letter from the last word, the string returned to the backing bean is:
Code: Select all
<h1 style="[%h1]">ENERGY STAR<sup>®</sup> Performance Ratng<br></h1>
Upon subsequent retrieval from the database, the special character is back in its original form, but the garbage character remains:
Code: Select all
<h1 style="[%h1]">ENERGY STAR<sup>®</sup> Performance Ratng<br></h1>
The problem simply continues, with another garbage character added each time the value is edited. For instance, deleting another character results in:
Code: Select all
<h1 style="[%h1]">ENERGY STAR<sup>�®</sup> Performance Ratg<br></h1>
I don't know if this is a problem with p:editor or if something else is to blame. I'm using PrimeFaces 4.0.24, but the behavior seems to be the same with version 5.1.8.