google-code-export / gwt-ckeditor

Automatically exported from code.google.com/p/gwt-ckeditor
2 stars 0 forks source link

setText() doesn´t work? #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Just create a simple CKEditor instance:
        CKConfig oCKConfig = new CKConfig(CKConfig.PRESET_TOOLBAR.BASIC);
        oCKConfig.setHeight("160px");
        oCKConfig.setLanguage("es");
        ToolbarLine oToolbarLine1 = new ToolbarLine();
        TOOLBAR_OPTIONS[] toolBarOptions1 = {
            TOOLBAR_OPTIONS.Bold, TOOLBAR_OPTIONS.Italic,
TOOLBAR_OPTIONS.Underline,TOOLBAR_OPTIONS.Strike, TOOLBAR_OPTIONS._,
            TOOLBAR_OPTIONS.JustifyLeft,TOOLBAR_OPTIONS.JustifyCenter,
TOOLBAR_OPTIONS.JustifyRight, TOOLBAR_OPTIONS.JustifyBlock, TOOLBAR_OPTIONS._,
            TOOLBAR_OPTIONS.Maximize
        };
        oToolbarLine1.addAll(toolBarOptions1);

        Toolbar oToolbar = new Toolbar();
        oToolbar.add(oToolbarLine1);

        oCKConfig.setToolbar(oToolbar);

        CKEditor ckEditor = new CKEditor(oCKConfig);
2. Call ckEditor.setText("test");

What is the expected output? What do you see instead?
I expect to see the editor rendered with the word "test" on it.
My view class does not render the CKEditor instance at all. This usually
happens when a Javascript exception is thrown somewhere. I tracked it down
and commenting/uncommenting the ckEditor.setText("test") line makes the
problem appear/disappear.

What version of the product are you using? On what operating system?
latest one gwt-ckeditor0.3.zip. But it seems to happen in version 0.2 as
well. Windows XP.

Please provide any additional information below.
Same problem seems to happen with setData too.

Original issue reported on code.google.com by uranio...@gmail.com on 3 Mar 2010 at 11:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Did you attach your instance of ckEditor to a Widget or Panel before trying to 
set 
the 
Text? 

Since the replaceTextArea is called when your instance is attached to your 
browser 
document, the JavaScriptObject won't be instantiated and you will receive an 
error.

We already fixed this issue by creating a waintingText String which will set 
the text 
only when ckEditor is attached. 

This modification is currently in the trunk repository and will be released 
with the 
next version of gwt-ckeditor

Original comment by emmanuel...@gmail.com on 3 Mar 2010 at 3:43

GoogleCodeExporter commented 9 years ago
Hi Emmanuel and thanks for your reply.

I have done what you explained, something along the lines of:

CKEditor oCKEditor = new CKEditor();
Panel oPanel = new Panel();
oPanel.add(ckEditor);
oCKEditor.setText("hello"); // Setting text AFTER instantiating and attaching 
to panel.

...then I attach the panel to the viewport, etc as usual.

But it still does not work. The problem is exactly the same as before.

Is there no other workaround that I try in the meantime? I need to be able to 
set
text in the box asap and I don´t know when you are planning to release the new
version (?).

Original comment by uranio...@gmail.com on 8 Mar 2010 at 11:53

GoogleCodeExporter commented 9 years ago
Hi Emmanuel,

As a temporary workaround I´ve added a small delay (1 second) before i attempt 
to use
the setText() method. It works fine although I don´t really like using little 
hacks
like these.

Anyway, thanks for your help and looking forward for the next release!

Francisco

Original comment by uranio...@gmail.com on 9 Mar 2010 at 6:39

GoogleCodeExporter commented 9 years ago
Hi Francisco,

In fact, the textarea is replaced by the Widget.onLoad method (inherited in
CKEditor). This method is called when the widget is attached to the document's 
body.
In your example, certainly you attach the CKEditor to a panel, but if this panel
isn't attached, in any way you want, to the document's body (In most cases, 
RootPanel
or RootLayoutPanel) , the onLoad method will never be called, the textarea will 
never
be replaced by the ckeditor, and then you can't set the text.

This fact will be treated in the next release by this way :
We keep an instance variable indicating if the textarea has been replaced. If 
not,
and if the setText is called anyway, we store the text in a variable, and set it
later, when the CKEditor is attached.

Regards,
Damien

Original comment by picard.d...@gmail.com on 9 Mar 2010 at 7:02

GoogleCodeExporter commented 9 years ago
I am trying to enable Scayt option of Ckeditor with GWT , Not getting any 
success 

Original comment by waliaspu...@gmail.com on 24 Jun 2011 at 6:53