title: Primefaces: p:textEditor and p:editor: how listen continuously for value change and focus change
body: <p><em>Primefaces 6.1, Primefaces Extensions 6.1, JSF Mojarra 2.3.0
  (Netbeans 8.2+Glassfish 4.1.1 OR Payara 4.1)</em></p>
  
  <p>I have multiple requirements, which I'd prefer to address without client-side JavaScript gymnastics (i.e. purely with Java backing bean listeners).</p>
  
  <p>R1. I need to be able to display continuously the current character count (vs. max allowed characters) below a <code>p:textEditor</code> or <code>p:editor</code> field (which feature BTW <code>p:inputTextarea</code> offers nicely out-of-the-box).</p>
  
  <p>R2. I need to be able to alert users to the fact that they have not saved changes (so I need to detect blur and focus events). One reason for this is that the editors are being used inside a composite component that in turn may be used many times inside nested <code>p:tab</code>/<code>p:accordionPanel</code> with many other form fields and buttons. Each encapsulated editor has its own Save button. A user might close a tab/accordion or move to another tab/accordion without saving, so I want a running warning message that the value has changed and has not been saved, and I want to growl users if they move away from the form field without saving changes.</p>
  
  <p>My first issue is that the <code>valueChangeListener</code> of <code>p:editor</code> and <code>p:textEditor</code> only seems to fire when I Save the changed value with a <code>p:commandButton</code> that processes the editor. Neither <code>p:editor</code> nor <code>p:textEditor</code> seem to support <code>p:ajax</code> listeners:</p>
  
  <pre><code>Unable to attach behavior to non-ClientBehaviorHolder parent
  </code></pre>
  
  <p>(This also means I can't just listen to 'focus' and 'blur' events.)</p>
  
  <p>[I tried PrimeFaces Extensions <code>pe:ckEditor</code>, which does permit <code>p:ajax</code> listening, but it has multiple other issues. For example, on catching the indeed continuous value change via <code>p:ajax</code> the value obtained form the UIinput source is always one character behind the actual input, breaking R1 (continuous character count).  It also does not seem to offer PrimeFaces Core style API ops that work with <code>widgetVar</code> such as <code>clear()</code>. And it does not seem to work with <code>p:resetInput</code>. It does however enable detection of 'blur' and 'focus'.]</p>
  
  <p>In any case, I would like to know how with <code>p:textEditor</code> and <code>p:editor</code> to:</p>
  
  <ul>
  <li><p>Continuously catch value changes and process them in backing bean listeners.</p></li>
  <li><p>Catch when users leave the editor field without having saved changes.</p></li>
  <li><p>Catch when users close a tab containing an editor without having saved changes.</p></li>
  </ul>