0
votes

I'm using primefaces(3.0.M2) rich editor for receiving input from user. The restriction is 5000 characters. When user tries to copy from external sources or beautify the content additional tags are getting added to preserve the format.

Now to validate the max length of 5000, I need to strip out the tags and only count the characters length. How to get the characters alone from in managed bean for validation?

client side validation snippet:

<p:editor    id="customerInfo"    value="#{companyBean.body}" 
      required="false"    requiredMessage="Info required"    height="250"    width="450"
      validatorMessage="Only 5000 characters allowed">
     <f:validateLength maximum="5000" />
 </p:editor>
1
Know that in primefaces 3.5 a new attribute was added for this maxlength : Integer Maximum length of the raw input. , <p:editor maxlength="5000" .... see this : code.google.com/p/primefaces/issues/detail?id=5068 - Daniel
Thanks Daniel. But I'm confined to 3.0.M2 - techie2k
Uhm, M2 is a beta ("milestone") version. Why not using a final/stable version? - BalusC
@BalusC <p:editor always fails with required=true or <f:validateLength... etc even with a final/stable version. (haven't tried with v4 yet) - fledglingCoder

1 Answers

0
votes

Just to help others like me, which tried to find some answer too!

You can user wigdteVar to access the editor value, like this:

 <p:editor
      id="iptTextoClausula"                     
      widgetVar="wvMyEditor"
      width="790"
      height="200"
      validator="clausulaEditorValidator"
      value="#{clausulasContratadasBean.selectedClauseFull.dsTexto}" />

<script language="Javascript">

     wvMyEditor.editor.doc.body.innerText

</script>