Test Kendo UI Scheduler with SAPUI5 using mockdata - sapui5

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.

Related

Azure Mobile App and navigation properties

I'm using an Azure Mobile App for a Xamarin Forms application and wondering if it is possible load navigation properties of an entity when getting it from the db?
Here is a code example:
"var menuItems = await client.GetTable'<'MenuItem'>'().ReadAsync();"
menuItem has a navigation property called comments. In postman I can load these by adding a parameter of $expand=comments on the end of my query string, I'm stuck on how to add this to the code in my app.
Answer #1: Use an [ExpandProperty] to automatically set $expand on the query. See chapter 3 of the Zumo Book at http://aka.ms/zumobook
Answer #2: You don't want to do this (HONEST!) It destroys any data normalization that you are trying to do.

PlayFramework with Scala, WebJars, ReactJS and RequireJS?

I am looking for an example about combining the four technologies in the title :) I have a working ReactJS application using Play, Scala and WebJars, it's here on GitHub.
Now I would like to add RequireJS, but I'm not sure how to go, especially because it seems to require a different JSXTransformer? If anybody has a pointer (or even a PR) it would be very appreciated.
This is not the easiest thing to do, but I was able to pull it off. I will give you some tips here. I also uploaded my own project to github. This is a very simple snake game built using React and RequireJs. It based on Webjars and Play Framework.
Remember that RequireJs is part of Play Framework. Here's a step by step guide to create React/RequireJs/WebJars/Play integration:
In your plugins.sbt add addSbtPlugin("com.github.ddispaltro" % "sbt-reactjs" % "0.5.2"). This is a plugin which transforms JSXes into JSes and also strips flow types if you want that.
In your main scala.html file add #helper.requireJs(core = routes.WebJarAssets.at(WebJarAssets.locate("require.js")).url, module = routes.Assets.at("javascripts/main").url). This will add add a script tag with data-main and src attributes that are used to bootstrap your RequireJs app.
Create react.js file in your assets/javascripts folder:
define(['../lib/react/react-with-addons'], function(React) {
window.React = React;
return React;
});
Create main.jsx file in your assets/javascripts folder:
require.config({
// standard requirejs config here
});
require(['react', 'components/YourComponent'], function(React, YourComponent) {
'use strict';
$(document).ready(function() {
React.render(<YourComponent />, document.getElementById('container'));
});
});
Your standard React component goes to assets/javascripts/components/YourComponent.jsx and is defined like standard RequireJs module. Remember to return a React class:
define(function(require) {
var React = require('react');
var AnotherComponent = require('components/AnotherComponent');
return React.createClass({ ... });
}
I hope that helps. If you have any questions, please let me know.
Someone said to have got the text plugin working with sbt-rjs: https://groups.google.com/forum/#!topic/play-framework/F789ZzTOthc
I would attempt with the text plugin first, as it's the simplest plugin of all, right? Once this is successful, move on to the JSX plugin:
https://github.com/philix/jsx-requirejs-plugin
Have a look at: https://github.com/nemoo/democratizer
This is an example project that uses play framework, scala, slick, mysql as a restful backend.
The client is a javascript single page application (SPA) written in react. It uses react router for client site routing and ES6 javascript.
The build process combines webpack and play activator which enables simple automatic browser refresh for server and client side code.

Import content from different CMS into episerver database

I am working on migrating a legacy CMS onto EPiServer CMS. I want to move the content from legacy CMS into EPiServer's database. Anyone ran into a scenario like this? I followed their document on world.episerver.com, but it is not very clear. It says to configure EPiServer site under config tab in Admin section to define Content Channel. But they do not talk about exactly what APIs to use and how different fields map in their database to EpiServer's database. Any help would be much appreciated.
You should not copy directly into the database since it is extremely difficult to get it right.
You need to start by building up your content types inside your project and then I think the easiest way to import the content would to build scheduled task or extend the admin interface with a import page.
In that you do your own mapping since you are the only one that knows what the things in the old CMS should be in EPiServer.
This is not an easy thing to do if you are new to EPiServer and I think that it might be the quickest way to contact expert services and they will then help end guide you.
Good luck!!
You can add page programmatically using EpiServer's IContenntRepository and IContentTypeRepositoiry as follows:
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.ServiceLocation;
PageReference parent = PageReference.RootPage;
IContentRepository contentRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>();
IContentTypeRepository contentTypeRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentTypeRepository>();
PageData myPage = contentRepository.GetDefault<PageData>(parent, contentTypeRepository.Load("StandardPage").ID);
StandardPage standardPage = contentRepository.GetDefault<StandardPage>(parent);
myPage.Property["PageName"].Value = "Name";
myPage.Property["MainBody"].Value = "My Page";
myPage.Property["PageTypeName"].Value = "Standard Page";
myPage.Property["PagePendingPublish"].Value = true;
myPage.URLSegment = EPiServer.Web.UrlSegment.CreateUrlSegment(myPage);
contentRepository.Save(myPage, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

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

drools guvnor upload POJO model jar

I like to creata package, POJO model asset with my java code ,using REST API.
Creating package with Apache HttpClient is fine, but I have problems creating a model asset, now I create "other assets, documentation" by putting the following
<entry xml:base="http://localhost:9080/repository/packages/package1/assets">
<title>testAsset1</title>
<summary>desc1</summary>
</entry>"
how do i make it a model asset? I tried to add a format tag but failed.
thanks
I think you can use the REST API to upload content. Send PUT request to URL something like
http://{server}/guvnor/rest/packages/{package name}/assets/{asset name}/source
Where asset name is the name of model assets. Not sure about what the mime type should be, a quick google search gave 'application/java-archive'
See the Guvnor REST API docs for more information.
You need to add below code to createAssetFromBinary method in PackageResource.java
ContentHandler handler = ContentManager.getHandler( ai.getFormat() );
if ( handler instanceof ICanHasAttachment ) {
((ICanHasAttachment) handler).onAttachmentAdded( ai );
}
You can also explore using standalone editor to create model & facts which will be stored directly in guvnor repository.