p:editor Primefaces的剩余字符

SXV*_*SXV 4 primefaces jsf-2

我知道Primefaces为p:inputTextarea提供了剩余字符的功能,如下面的代码所示

<p:inputTextarea rows="1" cols="85" counter="counter" maxlength="100" counterTemplate="{0} characters remaining" value="#{managedBean.inputvalue}" ></p:inputTextarea>
<h:outputText />
<h:outputText id="counter" />
Run Code Online (Sandbox Code Playgroud)

但是我想在p:editor中做同样的事情.怎么做?primefaces是提供这样的功能还是我必须通过其他方式实现这一点{比如编码这个功能}.

TIA

Ron*_*yen 7

<p:editor没有选择,你可以使用jquery来解决这个问题.我的解决方案是将key keyup事件绑定到我刚刚测试过的编辑器,我的示例有一个表单(id:fm),一个编辑器(id:rongnk),一个outputtext(id:txt):

<h:body onload="bindiframe()">
        <h:form id="fm"> 
            <p:editor id="rongnk" value="xxx">
            </p:editor>
            <h:outputText id="txt"/>
            <script type="text/javascript">
                var imax = 50;
                function bindiframe(){
                    $('#fm\\:rongnk').find('iframe').contents().find("body").on('keyup', function(e) {
                        ilength = $('#fm\\:rongnk').find('iframe').contents().find("body").text().length;
                        $('#fm\\:txt').html('Remain:' + (imax - ilength));
                    });
                }
            </script>
        </h:form>
    </h:body>
Run Code Online (Sandbox Code Playgroud)