OmiD
OmiD

Reputation: 231

set content of tinymce with a string of html

I have a JSF Renderer that uses responsewriter to generate a jsf page . In this class I create a String that contains html code , something like this :

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

when I create a tinymce editor and set the value of it with responsewriter like this :

   responseWriter.writeText(value, null);

it show exactly the same String (showing HTML tag) instead of HTML format of it.

I know it's Wrong to use writeText for writing HTML but I don't know what to use instead.

Upvotes: 1

Views: 658

Answers (2)

OmiD
OmiD

Reputation: 231

finally I solved my problem in this way : I set the value in a hidden like this :

    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");

and then I set it in my JSF :

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

Upvotes: 1

Alexander Willkomm
Alexander Willkomm

Reputation: 41

Try setContent.

responseWriter.setContent(s);

More information here: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent

Upvotes: 2

Related Questions