2013-04-04 99 views
0

我正在使用primefaces(3.0.M2)豐富的編輯器接收來自用戶的輸入。限制爲5000個字符。當用戶嘗試從外部源複製或美化內容時,會添加其他標記以保留格式。Primefaces豐富的編輯器

現在爲了驗證最大長度爲5000,我需要去除標籤並只計算字符長度。如何從託管bean中單獨獲取字符進行驗證?

客戶端驗證的代碼片段:

<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> 
+0

要知道,在primefaces這個*最大長度加入3.5的新屬性:原料輸入的整數最大長度*'< p:editor maxlength =「5000」....'看到這個:https://code.google.com/p/primefaces/issues/detail?id=5068 – Daniel 2013-04-04 06:09:13

+0

謝謝丹尼爾。但我僅限於3.0.M2 – techie2k 2013-04-04 06:15:58

+0

嚴格,M2是一個測試版(「里程碑」)版本。爲什麼不使用最終/穩定版本? – BalusC 2013-04-04 12:07:13

回答

0

只是爲了幫助別人像我一樣,它試圖找到一些答案呢!

可以用戶wigdteVar訪問編輯值,就像這樣:

<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> 
相關問題