我们的项目使用的是JSF框架,现在已经习惯了JSP与backingBean的组合
一般JSP上的各种标签都是绑定到backingBean的变量或方法<h:commandButton type="submit" value="#{sms.sms1001_send}" action="#{sms1001.send}" />现在决定使用FCKEditor这个编辑器
但是找了很久,都没有找到对应JSF的使用方法
我们现在保存一条东西,都还是在用这样的方式:<%@taglib uri="http://java.fckeditor.net" prefix="FCK"%> 
<FCK:editor instanceName="EditorDefault" width="455" height="460" value="" >
</FCK:editor>
然后backingBean里这样接:
/**
     * 获取FCKEditor写入的内容
     * @return
     */
public FacesContext getFacesContext()
{
return FacesContext.getCurrentInstance();
}  
public Map getParamMap()
{   
    return getFacesContext().getExternalContext().getRequestParameterMap();   
}      
public String getParamAsString(String paramName)
{   
    Object obj = getParamMap().get(paramName);   
    if (obj != null)
    {   
        return obj.toString();   
    } 
    else 
    {   
        return "";   
    }   

/**
  *保存
  */
public void save()
{
strContent=getParamAsString("EditorDefault");
System.out.println(strContent);
try
{
this.uccSave.save(strUId,strContent);
}
catch(Exception se)
{
se.printStackTrace();
}
strContent="";
}
暂时解决了保存的问题
可是如果要做读取、修改呢
现在完全不知道如何配合JSF,如何用FCKEditor来与backingBean中的变量进行保存,灵活的实现增删改查
期待大家指教或提出宝贵想法

解决方案 »

  1.   

    为什么问JSF的问题都没人回答
    难道JSF在国内就这么不济?
      

  2.   

    http://developer.51cto.com/art/200906/130944.htm
    不知道有帮助没!
      

  3.   

    http://www.blogjava.net/dyerac/archive/2006/12/29/73416.html
      

  4.   

    整合的话,你必须自己扩展出一个JSF的FCK组件。
    需要配置
    一个扩展的标签库(.tld),
    一个对应的标签类(继承 javax.faces.webapp.UIComponentELTag)
    一个渲染器(继承 javax.faces.render.Renderer)
    具体你可以先看看 JSF 的自定义组件。
      

  5.   

    感觉JSF方面,还是用的人比较少
    标准大致是那么四五家在弄,但是兼容性有些差了
      

  6.   

    我也在看FCKEditor,用jsf,你可以考虑用下面的方法:var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
    oFCKeditor.ReplaceTextarea() ;
    其中:new FCKeditor( 'FCKeditor1' )的'FCKeditor1'是jsf的textarea的id
      

  7.   

    <%@ page contentType="text/html; charset=UTF-8" language="java"
    import="java.sql.*" errorPage=""%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>FCKeditor测试</title>
    <script type="text/javascript" src="FCKeditor/fckeditor.js"></script>
    </head> <body>
    <form id="form1" name="form1" method="post" action="text.do">
    <table width="100%" border="0">
    <tr>
    <td height="25">
    <textarea name="contest" id="contest"
    style="width: 100%; height: 400px;"></textarea>
    <script type="text/javascript">
    var oFCKeditor = new FCKeditor('contest');
    //oFCKeditor.BasePath = 'FCKeditor/' ;
    oFCKeditor.ToolbarSet = 'Default';
    oFCKeditor.Width = '100%';
    oFCKeditor.Height = '400';
    oFCKeditor.Value = '';
    oFCKeditor.ReplaceTextarea();
    //oFCKeditor.Create() ;
    </script>
    <input type="submit" name="Submit" value="提交" />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    在这样的一个jsp 页面中  将 <textarea name="contest" id="contest"  style="width: 100%; height: 400px;"></textarea>
    提交到 servlet 中 取出保存。
      

  8.   

    我没用到FCKEditor,但是用到了jquery的calendar与JSF结合使用,没什么问题啊。 <script type="text/javascript">
    $(function() {
    $("#datepicker").datepicker({
    showOn
    : 'button',
    buttonImage :
    './images/calendar.gif',
    buttonImageOnly :
    true
    });
    });
    </script><h:inputText name="datepicker" id="datepicker" size="15"
    value="#{blistmemo.date}" valueChangeListener="#{blistmemo.act_selectDate}">
    <f:ajax event="change" render="rsList stat" />
    </h:inputText>
    在backbean里private String date;
    ...这样用没什么问题啊。我想FCKEditor是一样的,在页面上:<h:inputTextarea value ="#{bean.text}" name="content" id="content"></h:inputTextarea>
    <script type="text/javascript">
    var oFCKeditor = new FCKeditor("content");  
    oFCKeditor.BasePath = '${ctx}/fckeditor/' ; 
    oFCKeditor.Height   = 300 ;
    oFCKeditor.ToolbarSet = 'Basic';
    oFCKeditor.ReplaceTextarea() ;
    </script>不要把FCKEditor当一个独特的tag,而还是textArea对待,但有一个问题我还无法确定:就是里面内容的格式能否保存下来,你可以试试。
      

  9.   

    读取和jsf的textarea一样的用法..........
      

  10.   

    <%@taglib uri="http://java.fckeditor.net" prefix="FCK"%> 
    <FCK:editor instanceName="EditorDefault" width="455" height="460" value="" >
    </FCK:editor>在JSF 页面 ,这样可以显示吗 ?  
    我现在也在处理这个问题 ,一直出不来 。
      

  11.   


    public static void main() {
       System.out.println("哈哈哈哈");}