在jsf中使用ckeditor编辑器后页面的验证问题 以及自定义工具栏

这两天做一个关于新闻管理方面的项目 需要在线编辑系统  以前没搞过类似的东东 只好再网上找  大家推荐的是  ckeditor  相关的

说明也很多下面是一种对配置简单的做法

在已用的时候大致

配置方法 : 是从  http://blog.csdn.net/guoquanyou/article/details/6754990  复制过来的    是在jsp中得使用方法  可以说是比

较简洁的 而且兼容性比较好的

另外如果想去掉没用的工具栏的话  在onload方法里修改成以下代码

    window.onload = function(){ 
        CKEDITOR.replace('form1:content' , { toolbar:[
['Source','-','Save','NewPage','Preview','-','Templates'],  
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],  
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],  
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],  
['BidiLtr', 'BidiRtl'],  
'/',  
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],  
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],  
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],  
['Link','Unlink','Anchor'],  
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],  
'/',  
['Styles','Format','Font','FontSize'],  
['TextColor','BGColor'],  
['Maximize', 'ShowBlocks','-','About']  
   ]
            });

不想要那个工具就删除相应的 工具 就o啦

 

这里主要是说在jsf页面严正的时候 因为inputtextarea 标签会给 textarea标签包装一下  比如

<h:form id="form1" >

<h:inputTextarea styleClass="input_no_width" value="#{lowAdd.low.content}" id="content"></h:inputTextarea>

          <h:commandButton type="submit" οnclick="return  test()" value="添加" styleClass="btn" action="#

{lowAdd.addLow}" id="tianjia"></h:commandButton>

  </h:form>

 

在jsf展示的时候 回 把 id="content"  的id 替换成 id="form1:content"

并且如果用document.getElementById('form1:content').value 是得不出来的

 

在js验证页面内容的时候

 

 function check() {   

  submitflag = true;
     var editor_data = CKEDITOR.instances[0].getData(); 

//var editor_data = CKEDITOR.instances['form1:content'].getData();  //这样也可以

  var content=  document.getElementById('form1:content').value = editor_data;
  if (content =='') {
   alert('内容不能为空');
   submitflag = false;
    return false;
  }
  return true;

 }

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值