html_data for initial data and json_data for AJAX data in jstree - jstree

Can I configure jstree to use the html_data plugin to load the initial data and the json_data plugin to process subsequent AJAX data? Thanks!

If your first load data could be static then you simply use static json to load the first tree and then ajax to reload it.

Related

TinyMCE autosave plugin and localStorage

By default, TinyMCE's autosave plugin stores the editor's text in localStorage. Is there a way to tell it to use a different storage engine? Ultimately what I want to do is set up a listener on the storeDraft event so I can persist the contents to our server so the user can access the contents even after the autosave_retention limit has been surpassed. I know that I can set the autosave_rentention to 0 but even when I do I can see that it still writes the data to localStorage -- it just removes it (though, sometimes not immediately and it seems like a page reload short circuits that in some cases).
So basically, I'd like to hit 2 birds with one stone. I'd like to stop TinyMCE from storing the data in localStorage and, if I can specify a different "data store", then perhaps I can point it to my ajax handler which will persist to the back end.
Any advice would be greatly appreciated!
thnx,
Christoph
The autosave plugin is designed to work with local storage and has no option to change to a different storage mechanism. If you want to store the data on your server you would typically that with some custom code that uses either (a) TinyMCE events or (b) a timer to get the editor's current content and then send it to the server.
If you want to use TinyMCE events (https://www.tiny.cloud/docs/advanced/events/#editorevents) to trigger this process you would have code along these lines:
tinymce.init({
selector: "textarea",
...
setup: function (editor) {
editor.on('init change NodeChange Dirty', function (e) {
// 1. use getContent() to extract the editor's current HTML
// 2. send the HTML to your server
});
}
});
If you want to use a basic timer (e.g. setTimeout()) you would use that to trigger the same two actions as the sample code above.
In theory you could modify the autosave plugin to send data to your server as opposed to storing the data in local storage but I think you can do what you need in a far simpler way without needing to dig into the ~200 lines of code in the existing plugin.

Test Kendo UI Scheduler with SAPUI5 using mockdata

I'm tring to use Telerik KendoUI Scheduler in SAPUI5. I've found this article from SAP community on how to do it:
http://scn.sap.com/community/developer-center/front-end/blog/2016/01/20/working-with-kendo-ui-controls-in-sapui5
The problem is that for the moment I don't have a backend service, so I need to user mockdata to test it.
I'm tring to use sap mockserver class to simulate the backend service, but I don't understand how to set it and what is the URL for the OData service to call:
// Declare the URL for the OData service
var sServiceUrl = "/webapp/localService/mockserver"; --> ??
var pathUrl = "/Room_Set";
If you just want to see how you can integrate Kendo UI components to SAPUI5, I think creating a json model might work for you.
var oModel = new JSONModel();
var oModel.loadData('data/data.json'); // json file path
this.getView().setModel(oModel);
By the way a better option to implement this kind of third party frameworks is to create a custom control. It's better in many ways. https://www.youtube.com/watch?v=Nw8SnXZFqrs
To understand mock server worklist app would be a great place to look at. And also you check this link https://sapui5.hana.ondemand.com/#docs/guide/3a9728ec31f94ca18a7d543ce419d85d.html.

how to load external libraries into an SAPUI5 view?

In SAPUI5 I can load local files this way:
jQuery.sap.require("util.someFile");
But is it possible to load external libraries when required in some view using the above command or a similar approach? Ideally, I am looking for something like:
theLoadingCommand("some_url");
Thanks
Basically it is possible to register a module path to some URL.
jQuery.sap.registerModulePath('external.library', 'http://....'); //not working
There is only one problem with that. UI5 loads the resources via AJAX requests. Your browser will give you an error because you are trying to load files from a different host.
You can include external libraries by including the file in a normal script tag. It is also possible to include requireJS in your project and use its features. Unfortunately, at the moment UI5 doesn't support requireJS out of the box.
jQuery is supported by SAPUI5, so you can extend your heading from controller, for example:
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "http://somedomain.com/somescript";
$("head").append(s);

Access to controller variable from CoffeeScript

I have #list value in my controller and i have view where i m adding products.Form looks like product_name and Add Button.I need to add all thees values to #list thought ajax request using coffe script or some other way, where i will not submit whole form.
How to achieve that? Thanks.
Your question sounds quite strange...
First, any CoffeScript source will be compiled to Javascript, which is downloaded on the client side (in the browser). Your controller is running server-side, so it is only addressable through HTTP requests.
Nevertheless, an #list attribute is not persistent between two HTTP requests, so you will have to persist any change if you need to accumulate data, as you state in your question.
To achieve the AJAX call, I would recommend to use JQuery's helpers: http://api.jquery.com/jQuery.ajax/, or shortcuts like http://api.jquery.com/jQuery.get/, http://api.jquery.com/jQuery.getJSON/, ...
The rest is Rails routing, as can be teached in http://guides.rubyonrails.org/action_controller_overview.html#methods-and-actions and http://guides.rubyonrails.org/routing.html.
Hope this helps.

GWT - Is it possible to create new HTML elements (from the server) or i can just to update the ones loaded on the client?

Im new about this technology, but I would like to know if is possible to create new object (html elements, such div/span/and so on...) dinamically on server and send it to the client, or if i can just load the ones made on client-side when i develop it in the application.
I don't ask how to do it (i think its a delicate argument), but if I can, and (if yes) where i can get some stuff/example/tutorial to do this.
Example
What i usually do :
...
public void onSuccess(Boolean result) {
if(result) {
myFunction();
}
}
...
myFunction() {
InlineLabel label=new InlineLabel();
this.add(label)
}
What im looking for :
...
public void onSuccess(InlineLabel result) {
this.add(result)
}
So, i don't need to load in advance the Object, but load them only if i click on some button (or if i perform an action). This will save a lot of code (that is inutil, if i don't do any action) loaded (as JavaScript) on the client.
As usual, thanks for your time!
GWT does not support the pattern you showed, but you can achieve a similar effect with "code splitting": read http://code.google.com/webtoolkit/doc/latest/DevGuideCodeSplitting.html
With code splitting, the client only downloads the script it needs right away (configured by the developer). If, for example, the user navigates to a more complex area of the UI that requires more widgets, additional code will be downloaded.
I'm not entirely sure I understand your question, but please feel free to amend your question or post a comment if I've missed the mark.
The host page
A GWT app is loaded in the following (simplified) process:
A host page (HTML) is loaded
A bootstrapping script is loaded
A compiled app script is loaded
The host page can contain any HTML you want. The only requirement is that you include a <script> element that loads the GWT bootstrapping script.
As a result, you can have the server return a page that contains any server-generated markup you like.
Server-rendered HTML at runtime
Once your app is running, you can send off asynchronous requests in your code to retrieve arbitrary data from the server. One option is to retrieve server-generated HTML and insert it into your application.
For this option, you'll want to instantiate an HTML widget, then use its setHTML method to insert the server-generated markup into the widget.
Client-generated
As an alternative, you can retrieve structured data from the server via GWT RPC. Objects created on a Java-based server are serialised by GWT on the server and deserialised on the client back into regular objects. You can then pull data out of these objects using accessor methods (getName, getId, etc.). At this point, you have several options:
Generate some HTML using StringBuilder and the like, then use setHTML on an HTML widget.
Generate DOM elements with the DOM class
Set the data into widgets and add them to panels or the root panel.