【问题标题】:set content of tinymce with a string of html用一串html设置tinymce的内容
【发布时间】:2015-04-15 06:34:46
【问题描述】:

我有一个 JSF 渲染器,它使用 responsewriter 生成一个 jsf 页面。 在这个类中,我创建了一个包含 html 代码的字符串,如下所示:

 String s = "<b>hello</b> <i>world</i>" .

当我创建一个 tinymce 编辑器并使用 responsewriter 设置它的值时:

   responseWriter.writeText(value, null);

它显示完全相同的字符串(显示 HTML 标记)而不是它的 HTML 格式。

我知道使用 writeText 编写 HTML 是错误的,但我不知道改用什么。

【问题讨论】:

    标签: html jsf httpresponse tinymce-4


    【解决方案1】:

    试试 setContent。

    responseWriter.setContent(s);
    

    更多信息在这里:http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent

    【讨论】:

      【解决方案2】:

      最后我以这种方式解决了我的问题: 我将值设置为这样的隐藏:

          responseWriter.startElement("input", null);
                  responseWriter.writeAttribute("type", "hidden", null);
                  responseWriter.writeAttribute("id", "tinymcevalue" , null);
                  responseWriter.writeAttribute("name", "required-" + filerRichTextEditor.getSchemaName(), null);
      
      
                  responseWriter.writeAttribute("value", getDocumentFieldValue(filerUIComponent.getSchemaName()), null);
                  responseWriter.endElement("input");
      

      然后我将它设置在我的 JSF 中:

         tinyMCE.activeEditor.setContent(document.getElementById("tinymcevalue").value);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-04-06
        • 1970-01-01
        • 1970-01-01
        • 2012-07-31
        • 2016-04-02
        • 2016-04-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多