Hi Leon,
Leon Wang wrote:
Hi Marius,
Since the first approach which is "1) edit the wysiwyg_createEditor velocity
macro from macros.vm" is simpler, I will modify macros.vm. You said "new
WysiwygEditor($jsVarName); with something like window["${fieldId}_editor"] =
new WysiwygEditor($jsVarName);" Could you please explain briefly what does
"window["${fieldId}_editor"]" mean? What is it for? Is it a function
of
javascript? In the macros.vm I found "Wysiwyg.onModuleLoad(function() {new
WysiwygEditor($jsVarName); $jsVarName = undefined;});", I did not find any
"window" stuff.
"window" is a predefined JavaScript object. See
http://w3schools.com/jsref/obj_window.asp . It has global scope so you
can access its properties everywhere. My suggestion was to save a
reference to the editor instance on the window object so that you can
access the editor later.
So after the first step, I got the reference, is the reference stored
in window["${fieldId}_editor"]
variable?
You should be able access the editor using window['content_editor'] in
JavaScript.
Since don't depend at all on WYSIWYG Java code is not possible and do not
bring you more work, I think should go with "i) access the editor in Java
(GWT) code by writing a simple native getter". For the code you provided
"editorJSReference.@com.xpn.xwiki.wysiwyg.client.editor.WysiwygEditorApi::editor;"
I never saw code like this, is the @ for Java annotation or Component? Is
there any document I can read to learn about the related
rationale/knowledge? 'cause I have no clue what it means. So this line will
return the WYSIWYG editor's reference restored/declared in the macros.vm
file?
That is GWT's JavaScript Native Interface (JSNI) notation. See
http://googlewebtoolkit.blogspot.com/2008/07/getting-to-really-know-gwt-par…
. Replace editorJSReference with window['content_editor'].
I tried to add a new page in the draft document for Loading GWT in Xwiki
page, It seems I can't add new page, only editing existing document. Should
I add something behind your "Writing GWT applications in XWiki", so you
could create a new one or something else. If there are work I can do to save
your time or to make Xwiki better, feel free to assign me the work. I am
more than happy to help.
I created
http://dev.xwiki.org/xwiki/bin/view/Drafts/LoadingGWTApplicationsInXWiki
for you.
Hope this helps,
Marius
Thank you for taking your time to help me!
-Leon
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs