|
Re: Own form widget - close event not fired ? [message #1828214 is a reply to message #1828212] |
Thu, 04 June 2020 08:48 |
|
Hi Miloslav
Since you're in a Scout Classic application, the _close method in Form.js is never called. In Scout classic the whole widget lifecycle is controlled by the UI-server. Thus overriding the _close method makes only sense in a Scout JS application (without UI server).
However: the opposite operation of "_render" is not _close but "_remove". Render/remove are used when a Scout widget is rendered in the HTML document, and removed from the HTML document. Note that a Scout widget instance may exist without being rendered to the HTML document. In case you need to hook into the widget instance create or destroy process, you'd rather override "_init" and "_destroy" (see Widget.js).
Maybe you should also consider to implement a TinyMCEEditorField which extends AbstractBasicField to integrate the TinyMCE editor. This would allow you the re-use the editor in any Form in your Scout application and not only in this special form.
Cheers,
André
Eclipse Scout Homepage | Documentation | GitHub
[Updated on: Thu, 04 June 2020 09:12] Report message to a moderator
|
|
|
|
Re: Own form widget - close event not fired ? [message #1828219 is a reply to message #1828216] |
Thu, 04 June 2020 09:22 |
|
You don't find that field anywhere, it was just a suggestion to implement it yourself ;-)
Since WYSIWYG editors like TinyMCE must be licensed in a commercial context, we cannot open-source a Scout integration. However, I have some experience with integration of commercial editors into Scout (Froala, Squire) . We've implemented these editors as a sub-class of AbstractBasicField. When you know how to implement a custom widget in Scout and only need to support the text-formatting features of the editor, this is a relatively simple task, since everything can be handled over the value of the field, which is a String that contains the HTML code. But when you must support other features like drag & drop, image- or file-upload and integrate these features with your Scout application you should prepare for a lot of coding.
Eclipse Scout Homepage | Documentation | GitHub
|
|
|
Re: Own form widget - close event not fired ? [message #1828395 is a reply to message #1828219] |
Tue, 09 June 2020 07:40 |
Miloslav Frajdl Messages: 55 Registered: June 2018 |
Member |
|
|
Hello.
I have one more question. I modified the call in the new widget as follows:
fitbig.TinyMCEForm = function() {
fitbig.TinyMCEForm.parent.call(this);
};
scout.inherits(fitbig.TinyMCEForm, scout.Form);
fitbig.TinyMCEForm.prototype._render = function() {
this._renderForm();
window.tinymce.init({selector: '.tinymce textarea'});
};
fitbig.TinyMCEForm.prototype._remove = function() {
alert(window.tinymce.activeEditor.getContent()); // This works, editor content is displayed.
var tinymcefield = scout.getSession().desktop.activeForm.rootGroupBox.fields[2];
tinymcefield.setValue(window.tinymce.activeEditor.getContent()); // No error, but form field has no value
document.cookie = 'TinyMCEFormResult='+window.tinymce.activeEditor.getContent(); // Cookie is right set, but I can't read it in Java.
// Default code from Form.js
this.formController.remove();
this.messageBoxController.remove();
this.fileChooserController.remove();
if (this._glassPaneRenderer) {
this._glassPaneRenderer.removeGlassPanes();
this._glassPaneRenderer = null;
}
this._uninstallFocusContext();
this.$statusIcons = [];
this.$header = null;
this.$statusContainer = null;
this.$close = null;
this.$saveNeeded = null;
this.$icon = null;
this.$title = null;
this.$subTitle = null;
scout.Form.parent.prototype._remove.call(this);
}
Using the form in Java:
HtmlEditorForm form = new HtmlEditorForm(); // In this form is used widget.
form.startNew();
form.waitFor();
//String result = CookieUtility.getCookieByName(req, cookieName) // Can't read cookie, I can't get current http request
MessageBoxes.createOk().withBody(form.getContentField().getValue()).show(); // Display empty value
_render works fine - TinyMCE editor is shown and work.
Unfortunately, I can't transfer its contents to a form field. In _remove alert show editor content, I try set value to formfield or set cookie value. Setting value not work, cookie I can't read in Java.
It's hard for me to figure it out on my own, but I need to use TinyMCE (or some other WYSIWYG editor) in the form.
Can anyone advise me? How do I fill the value of a form field in Javascript? Or how do I read the value of a cookie in Java? Or some better solution?
Thank you.
|
|
|
Re: Own form widget - close event not fired ? [message #1828411 is a reply to message #1828395] |
Tue, 09 June 2020 10:38 |
|
As I said, first you need to understand the basic concepts of Scout and how to build a custom widget with Scout. I'd recommend to analyze the HeatMap-widget (see this thread here).
When you have a TinyMCEField this field alone should be responsible to initialize and render/remove the TinyMCE Editor (basically it works like a more sophisticated StringField). You should not require a special Form to deal with TinyMCE. This means the TinyMCEField also must set the value and must synchronize the value in the browser with the model on the UI-server using Scout's JSON protocol. The HeatMap widget is a good starting point to understand which parts (like the JSON layer) are required. I'd also recommend to start up the Dev-Tools in your browser, open the Network tab and analyze what happens when you type something into a StringField. Exactly the same thing should happen, when your TinyMCEField updates the value on the UI-Server (or must render a value set by the UI-Server).
Sending the value via Cookie looks like a conceptual error to me.
Eclipse Scout Homepage | Documentation | GitHub
[Updated on: Tue, 09 June 2020 12:24] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04042 seconds