Infor Mashup SDK Developers Guide Mashup SDK
Infor Mashup SDK Developers Guide Mashup SDK
Developers Guide
Mashup SDK
Copyright © 2016 Infor
Important Notices
The material contained in this publication (including any supplementary information) constitutes and
contains confidential and proprietary information of Infor.
By gaining access to the attached, you acknowledge and agree that the material (including any
modification, translation or adaptation of the material) and all copyright, trade secrets and all other
right, title and interest therein, are the sole property of Infor and that you shall not gain right, title or
interest in the material (including any modification, translation or adaptation of the material) by virtue
of your review thereof other than the non-exclusive right to use the material solely in connection with
and the furtherance of your license and use of software made available to your company from Infor
pursuant to a separate agreement, the terms of which separate agreement shall govern your use of
this material and all supplemental related materials ("Purpose").
In addition, by accessing the enclosed material, you acknowledge and agree that you are required to
maintain such material in strict confidence and that your use of such material is limited to the
Purpose described above. Although Infor has taken due care to ensure that the material included in
this publication is accurate and complete, Infor cannot warrant that the information contained in this
publication is complete, does not contain typographical or other errors, or will meet your specific
requirements. As such, Infor does not assume and hereby disclaims all liability, consequential or
otherwise, for any loss or damage to any person or entity which is caused by or relates to errors or
omissions in this publication (including any supplementary information), whether such errors or
omissions result from negligence, accident or any other cause.
Without limitation, U.S. export control laws and other applicable export and import laws govern your
use of this material and you will neither export or re-export, directly or indirectly, this material nor any
related materials or supplemental information in violation of such laws, or use such materials for any
purpose prohibited by such laws.
Trademark Acknowledgements
The word and design marks set forth herein are trademarks and/or registered trademarks of Infor
and/or related affiliates and subsidiaries. All rights reserved. All other company, product, trade or
service names referenced may be registered trademarks or trademarks of their respective owners.
Publication Information
Release: Infor Program Cost Ledger
Publication date: August 26, 2016
Document code:
Contents
Contents
API ..................................................................................................................................... 15
OpenSourceLicenses .............................................................................................................. 15
Samples ................................................................................................................................... 15
NodeJS .............................................................................................................................. 16
Projects.............................................................................................................................. 16
Web ................................................................................................................................... 16
Source ............................................................................................................................... 16
External framework versions....................................................................................... 16
Proxy .............................................................................................................................................. 16
Using a proxy with Chrome ..................................................................................................... 17
Samples ......................................................................................................................................... 17
Web server .............................................................................................................................. 18
Installing the web server ................................................................................................... 18
Starting the web server ..................................................................................................... 18
Stopping the web server ................................................................................................... 18
Proxy ........................................................................................................................................ 18
Configuring the proxy ........................................................................................................ 18
Starting the proxy .............................................................................................................. 19
Stopping the proxy ............................................................................................................ 19
Configuring multiple proxies .............................................................................................. 19
Testing the sample applications .............................................................................................. 20
Sample projects ............................................................................................................................. 20
Common .................................................................................................................................. 20
Applications ............................................................................................................................. 20
M3 ............................................................................................................................................ 20
Visual Studio project files .................................................................................................. 21
Version log
The version log describes the changes between versions of this document.
Organization
This table shows the chapters of the guide:
Section Description
Contacting Infor
If you have questions about Infor products, go to the Infor Xtreme Support portal at
www.infor.com/inforxtreme.
If we update this document after the product release, we will post the new version on this Web site.
We recommend that you check this Web site periodically for updated documentation.
If you have comments about Infor documentation, contact documentation@infor.com.
Purpose
The purpose of this document is to describe how to set up a development environment and build
web applications using the Mashup SDK.
The purpose of this document is not to describe how to develop web applications in general; instead
it contains information about specific APIs for the Mashup SDK that you can use in your applications.
Disclaimer
Please note that only classes and functions documented in the Mashup SDK API Documentation are
publically available for you to use. Anything that is not documented or explicitly marked with
“internal” in the API documentation should not be used. Classes and functions that are not intended
for public use may be removed or changed in future versions without notice.
Role Skills
Chapter 2 Overview
2
The Mashup SDK is used to build web applications with a focus on M3 related products. The SDK is
based on open web technologies such as AngularJS, TypeScript and Bootstrap. Existing M3
functionality can be reused through MI programs or panels from interactive M3 programs. The SDK
is targeted at experienced web developers familiar with HTML 5, CSS and scripting.
The UI uses standard controls in HTML5 and additional controls from the Angular UI implementation
of Bootstrap. The SDK and the examples are built in TypeScript that compiles to standard
JavaScript.
Technologies
The intention of the Mashup SDK is not to create a large framework that tries to solve everything but
rather to reuse existing open source frameworks and add only functionality that is missing or that is
specific to Infor applications such as M3.
The main technologies we have chosen to use for the Mashup SDK are TypeScript, AngularJS and
the Angular UI implementation of Bootstrap.
TypeScript
This is the pitch for TypeScript from http://www.typescriptlang.org/
- TypeScript lets you write JavaScript the way you really want to.
- TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
- Any browser. Any host. Any OS. Open Source.
It is our experience that TypeScript gives real benefits for web development. You are more
productive and produce less bugs. The code is also easier to maintain and it is possible to use
refactoring.
If you really don’t want to use TypeScript you don’t have to since the framework is compiled to plain
JavaScript. Note that all our documentation and samples are for TypeScript so you probably need to
be able to read and understand TypeScript code and how it translates to plain JavaScript.
AngularJS
AngularJS is an extensible framework for building large web applications. It is open-source and
maintained by Google and the community.
https://angularjs.org
UI Bootstrap
UI Bootstrap is a native AngularJS implementation of Bootstrap. Bootstrap is a framework for
developing responsive, mobile first web applications.
http://angular-ui.github.io/bootstrap
Requirements
Visual Studio 2013 (Express 2013 for Web or better) or Eclipse
User account with access to an M3 environment (when using the M3 framework).
Chapter 3 Development
environment 3
This chapter describes how to setup the Mashup SDK development environment.
Prerequisites
This section describes the prerequisites for the Mashup SDK. Some of these prerequisites are
optional so you should read this section and determine which prerequisites you really need before
installing them.
NodeJS
A NodeJS installation is required if you want to use the proxy and web server that are part of the
Mashup SDK. The proxy is used to get around cross domain calls during development. The web
server is used for running the samples but can also be used for development. If you already have a
working NodeJS installation or if you don’t intend to use the proxy or the web server you can skip
this section.
Install NodeJS
Download and install NodeJS from http://nodejs.org/
When the installation is complete you can follow the steps in the next two sections to verify that
installations works. Note that these instructions only applies to Windows clients.
Developer tools
You will need some kind of developer tool and if you are using Windows we would recommend
Visual Studio. If you are using another operating system we would recommend Eclipse. These are
just recommendations however and there are other tools that you could use instead.
Visual Studio
Microsofts Visual Studio has support for web projects and has a built-in development web server.
Visual Studio 2013 Update 3 and later has support for TypeScript editing, compiling and debugging.
If you have Visual Studio 2012 you can install a TypeScript editor plugin. You will find in on
http://www.typescriptlang.org under Tools.
The sample projects in the Mashup SDK are in Visual Studio format. The contents of the sample
projects can of course be used with other developer tools but that requires some manual setup.
Other tools
In addition to Visual Studio and Eclipse you can use any other tool you might prefer. You could even
use a text Editor such as Notepad++ and the TypeScript Node.js compiler.
M3
Web
o Source
fonts
odin
This section will give you an overview of the contents of each folder.
Additional
The Additional folder contains additional files that are bundled with the Mashup SDK. The folder
currently only contains one file, the SDK for Mashup Everywhere which is used to implement Web
Mashup controls.
Documentation
The documentation folder contains the Developers Guide in PDF format. This is the document you
are now reading.
API
The API folder contains API documentation generated from the framework TypeScript files. Open
the index.html file in a browser to view the API documentation.
OpenSourceLicenses
License text files for the frameworks used.
Samples
The Samples folder contains samples projects and pre-built sample applications. There is also a set
of command files that can be used to install the NodeJS web server, start the web server, start the
proxy etc. More information about how to test the samples can be found in the Samples and Sample
project sections further down in the document.
NodeJS
The NodeJS folder contains the JavaScript source files for the proxy and the web server.
Projects
The Projects folder contains Visual Studio projects for the sample applications. The Common folder
contains samples for the common framework. The M3 folder contains samples for the M3
framework. The Application folder contains small applications samples that use functionality from
both the common and M3 framework.
Web
The Web folder contains pre-built versions of the sample applications and some tools.
Source
The source directory contains the Mashup SDK framework files and external framework files.
Angular UI grid
The grid component used by some of the controllers and services in the Mashup SDK is the Angular
UI Grid. This is the successor of the Angular ngGrid. The Mashup SDK contains the v 3.1.0 build of
that component. If you have any issues related to the grid please try and update the UI grid
component to see if that helps. It is also possible that their API will change in the future which might
affect the Mashup SDK.
New versions of the UI Grid can be downloaded from http://ui-grid.info/
Proxy
The Mashup SDK contains basic proxy that runs on NodeJS. The proxy can be used during
development to get around the cross domain request restrictions in browsers. The proxy can be
configured to tunnel traffic from a port on localhost to web server on a remote machine. When
developing the browser loads your application from localhost and therefore it will allow calls to the
proxy that also runs on localhost. The benefit of this is that you don’t have to deploy your application
code to the remote web server during development.
If you use services from an application that has enabled Cross-origin resource sharing (CORS) you
don’t have to use a proxy.
You can also use a Windows desktop shortcut with the following text in the target field to start an
instance of Chrome without web security:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security
When running Chrome without web security you should see a warning similar to the one in the
screenshot below. If you don’t see this message you might have to close all running instances of
chrome.exe. If you closed all Chrome windows there might still be an instance running in the
Windows task bar tray. You can verify that no instances of chrome.exe is running using the Windows
Task Manager. You can also uncheck the “Let Google Chrome run in the background” setting on the
Chrome icon in the Windows task bar tray.
Samples
The sample applications can be tested without any developer tool by using the web server and proxy
that are part of the Mashup SDK. The web server is required for all samples but the proxy is only
required for samples that use M3 data. Follow the steps below configure and test the sample
applications.
Web server
To test the samples you need to have a web server installed and started.
Proxy
To test the M3 samples you need to have a proxy configured and started for an existing M3 BE
installation.
- Open the package.json file, located in the Nodejs folder, in a text editor.
- Change the hostname and the last port number of the script command property named
“proxy” according to your environment.
o Use the same hostname that is used for the certificate on the server.
o Use the HTTPS port number from the Grid.
o Leave the first port number the same (8081) since this should always be the same.
o Example:
“proxy”: “node proxy.js 8081 server.infor.com 40004”
- Save the file.
All sample applications use port 8081. If you can’t use port 8081 for some reason you must update
the sample applications that use the proxy with the new port number.
Sample projects
The Projects folder contains the projects and source code for the sample applications.
Common
Contains sample projects using functionality in the common framework. The HelloWorld project
shows a minimal web application. The Framework projects shows how to use services and directives
from the common framework. The OdinStyle project show how to use the parts of the common
framework related to style and layout.
Applications
Contains a couple of small M3 application projects using the customer entity in M3.
M3
Contains a sample project with M3 specific functionality.
Most sample projects include multiple samples in different folders. Most samples does not have a
default index.html file which means that you must select which sample to run by opening the context
menu on the index.html and select “Set As StartPage”. You can also choose to have the
CurrentPage as start page which means that you have to open a specific index.html before pressing
F5 to debug the solution.
This chapter describes how to create a Mashup SDK project using either Visual Studio or Eclipse.
Visual Studio
This section describes how to create a very simple project from scratch, how to create an application
and how to debug it. The example project is similar to the HelloWorld sample application in the
Samples folder.
module HelloWorld {
<!DOCTYPE html>
<html ng-app="helloworld">
<head>
<title>HelloWorld</title>
<link href="odin/bootstrap.min.css" rel="stylesheet" />
<link href="odin/bootstrap-theme.min.css" rel="stylesheet" />
<link href="odin/odin-default-min.css" rel="stylesheet" id="odin-theme" />
</head>
<body>
<odin-navbar header="Hello World Application" theme="true"></odin-navbar>
<script src="odin/jquery.min.js"></script>
<script src="odin/angular.min.js"></script>
<script src="odin/ui-bootstrap-tpls.min.js"></script>
<script src="odin/odin.js"></script>
<script src="app.js"></script>
</body>
</html>
Troubleshooting
Eclipse
This section describes how to create and configure a project using Eclipse. The following
instructions are made for a specific Eclipse plugin so they will not apply if you choose to use another
plugin for TypeScript in Eclipse.
b. TypEcs: Should be possible to debug. But must add references to all used typings in
the ts files. It’s also difficult to use linked resources/folders.
9. Click Confirm
10. Accept the license agreement
11. After the installation Eclipse will want to restart, let it!
12. Install AngularJS Eclipse from Eclipse Marketplace
13. Create a project: File > New > Project, Javascript project
14. Name the project and click finish.
15. Right click on the project > Configure > Enable Typescript builder
16. Right click again on the project and select Configure > Convert to AngularJS Project
17. Change properties (Window > Preferences or in Project > Properties) for typescript to:
18. In Preferences > Tern, change Node.js install to “Native Node.js” and make sure that the
“Native path” is correct.
23. Import the Hello World project by right clicking the src folder and selecting import. Locate the
helloworld folder (…\Infor_MashupSDK\Samples\Projects\Common\HelloWorld\helloworld),
select all files and select the option “Create top-level folder”.
24. After you have created your application you can run it by right-clicking the .html file and
select Open With > Web browser
25. To indent use Ctrl+Shift+F
26. You will probably also get a lot of “The word “x” is not correctly spelled” warnings. To skip
these warning change the settings in Window > Preferences > General > Editors > Text
Editors > Spelling. There you can turn of spellchecking completely.
Chapter 5 Deploying an
application 5
This chapter describes some of the options for deploying an application built using the Mashup SDK.
M3 application deployment
If your web application is part of a Grid application it will most likely be deployed as part of the Grid
application and packaged in a GAR-file (Grid Archive). As long as the Grid application is deployed in
the same Grid as M3 you won’t have any issues with cross domain calls.
If your application only consists of client files you have the option to deploy it in the M3 UI Adapter
(MUA) server. The MUA server has support for hosting web applications from version 10.2.2.0 and
later. The functionality is rather basic in that you simply create a zip file of your application and
upload it using the Applications tab in the MUA web based administration tools. The name of the zip
file will be used to create a directory where the application files are stored on the MUA server.
Example:
If you create a zip file called demo.zip that contains a file called index.html in the root and deploy
that in the MUA server it would be accessible using this path:
/mne/apps/demo/index.html
This chapter is an overview of the different areas of the common framework. To get more details of
each area refer to the API documentation and the sample projects.
Startup
The framework have services and classes that can be used for the startup of the application. The
startup functionality can be used to perform one or many asynchronous operations such as server
requests before the rest of the application is allowed to start. The reason for providing this
functionality is that Angular currently lacks standard support for this.
The startup functionality is optional in most cases but some framework components rely on being
notified of the framework ready state. If you want to use these components but don’t want to use the
startup functionality there are some things you need to do to make the components work.
Ex:
rootScope["odinReady"] = true;
module Example {
class App extends Odin.ApplicationBase {
public onStart() {
this.name = "Application Example";
this.version = "1.0.0";
this.module = angular.module("example", ["ui.bootstrap", "odin"]);
this.module.controller("ExampleCtrl", ExampleCtrl);
}
}
new App().start();
}
Startup service
If you don’t want to use the application base class for some reason you can call the startup service
manually. Refer to the API documentation of Odin.IStartupService.
Client logging
The Odin.Log class can be used to log messages on the client. The output of the log is written to the
browser console by default. It is also possible to create a custom log appender and to disable output
to the browser console.
The supported log levels are fatal, error, warning, info, debug and trace. The default log level is info.
The log level can be changed by the application and it can also be changed by executing a function
in the browser console. The example below changes to the debug log level.
Ex:
Odin.Log.setDebug();
The first requirement can be solved by watching properties on the Angular JS root scope and this is
what we use in the implementation. The next two requirements do not have an obvious solution in
AngularJS.
The background for the requirements is that we don't want to issue multiple server requests while a
response is pending and to prevent loading data from a server for parts of the UI that is not visible.
One example is selection changed events in a list that triggers a server request. If the user clicks on
multiple list rows a number of server request may be issued. Another example is a tab control with
multiple tabs. In most cases it does not make sense to load the data for tabs that are not visible until
the user actually selects that tab. Manually implementing support for this in each controller is quite a
bit of work so the component framework is an attempt to reduce the amount of code that is required.
The component framework consists of a couple of different parts such as the component service,
component context, visual state etc.
Component service
The component service (Odin.IComponentService) is used to register components and raise events.
When a component is registered a component context is returned.
Component context
The component context (Odin.IComponentContext) keeps track of the state of the component
(Odin.ComponentState). The component state can be active or busy. When a component is not
active events for that component will be delayed. A component is considered to be active if the
component state is active and the component is visible. A component may not be visible if visual
state handling is enabled.
The component context can be used to raise events which is a shortcut to using the component
service.
Visual state
The visual state (Odin.IVisualState) is used to keep track of components that can be activated or
deactivated. A common example are tabs in a tab control. When a tab is selected the visual state is
considered to be active, when the tab is not selected the state is inactive. Another example is an
expander control that can be expanded (active) and collapsed (inactive). The visual state can also
be used for things that are not visible in the UI but can be active/inactive.
The visual state functionality is not automatic so to enable it you must use either the
Odin.VisualStateCtrl class or the Odin.TabCtrl class.
Layout
The Mashup SDK uses the Bootstrap 3.0 grid system for layout.
You can use the Bootstrap CSS classes directly but there are also some directives in the Mashup
SDK that simplifies layout of form elements for example. The OdinStyle sample project contains
examples of how to use the directives and many of the other samples also use the directives.
More information about the Bootstrap grid system can be found here:
http://getbootstrap.com/css/#grid
http://getbootstrap.com/examples/grid/
Translation
The translation solution is based on script files as language file with language constants mapped to
language texts. The Mashup SDK is delivered with a standard.js file that contains a set of common
language texts. Some of them are used within the framework such as OK, Cancel, Yes and No, but
most constants are there for your convenience.
It is recommended that you add your own application.js file with the language constants for your
application. You can choose to copy the constants that you would like to use from standard.js and
only use one language file instead of two by configuring the ILanguageService. The language
constant key has to be unique not only within a single file but also unique when compared to the
constants in the standard.js file. This is because standard.js and application.js files will be mixed
together if the ILanguageService is configured to load both files.
The language files are located in the scripts/localization folder. There is one subfolder per language.
The Samples contains a translation example that shows the use of the service and odin-lang
(LangDirective). See Samples -> M3 -> Translation.
There is currently no support for incremental load of language constants for different pages in a
navigational application.
Click Translate
Since there might be conflicting constants in the two files the tools have different options for
adding prefixes. The output from this tool can be copied to your language file.
This chapter is an overview of the different areas of the M3 framework. To get more details of each
area refer to the API documentation and the sample projects.
Startup
The startup functionality for the M3 framework is exactly the same as for the common framework but
it is possible perform some M3 specific operations during startup. If the application requires a M3
user context or an interactive session the framework can ensure that this is available before the
application starts. The other option is to rely on the lazy loading of the user context for example but
the application will have responsibility for waiting until the user context is available.
module M3Example {
class App extends M3.ApplicationBase {
public onStart() {
this.name = "M3 Application Example";
this.version = "1.0.0";
this.userContext = true;
this.module = angular.module("m3example", ["ui.bootstrap", "odin", "m3"]);
this.module.controller("M3ExampleCtrl", ExampleCtrl);
}
}
new App().start();
}
MI programs
The M3 framework has support for calling M3 MI programs using the REST endpoint on the BE
server. To be able to call the MI programs the application must be deployed in the same Grid as M3
Foundation. During development you can use the proxy to call MI programs even though the
application is running locally on a developer machine.
MI Service
The MI service can be used to call transactions in M3 MI programs. The MI service can be called
directly or it can be used through the MI controller base classes described below.
Interactive programs
The M3 framework has support for using stateless form detail panels or stateful form list panels. To
be able to use the interactive programs the application must be deployed in the same Grid as the M3
UI Adapter. During development you can use the proxy to call interactive programs even though the
application is running locally on a developer machine.
An interactive M3 program is a regular form based M3 program such as MMS001 or CRS610. You
normally run interactive programs in Smart Office using MForms or in a browser using Ming.le and
H5. The M3 framework can be used to reuse parts of the interactive program functionality in an
application. Note that the functionality that can be reused is limited and that the the full functionality
of the interactive programs can only be used in the MForms or H5 clients.
Interactive session
An interactive user session is required when using stateless detail panels or stateful list panels
described below. When a Mashup SDK application runs in a H5 tab it will try to reuse the existing
interactive user session from H5. If the application is running stand-alone or hosted in some other
container the M3 framework will create an interactive session. Since an interactive session has state
on the M3 server the framework will attempt to log out the session when the browser closes or
navigates to another page.
Stateless detail panels can be used by extending the M3.Form.DetailCtrl class and using the m3-
detail-layout directive.
Stateful list panels can be used by extending the M3.Form.ListCtrl class and the m3-list directive.
It is possible to integrate Web Mashups and Web Mashup controls with applications created using
the Mashup SDK in a couple of different ways. The most basic integration is to just load a Web
Mashup in an iframe. Other options are to integrate a single Mashup control or to create Web
Mashup using an event proxy control.
Extend the Angular controller responsible for Mashup Integration with Odin.MashupCtrl.
Example:
export class myAppCtrl extends Odin.MashupCtrl
Create an event callback in your controller. It’s highly recommended that you filter events based on
the event name (eventName) since the proxy web control will send events that might not be relevant.
The event name will be what you set the TargetEventName to be in the WM XAML, if no
TargetEventName is set then the event name will be the value of SourceEventName.
Example:
public receiveEvent = (e: Odin.IMashupEvent): void => {
if (e.eventName == “myEvent”) {
// Act on this event
}
}
Place an <odin-mashup></odin-mashup> tag where you want your web mashup iframe to be
displayed and set the following attributes:
id – regular html id attribute
src – the source of your web mashup, used the same way as the src attribute in a regular iframe
event-callback – the event callback in your controller
Ex
. <odin-mashup id=”myMashup” event-callback=”ctrl.receiveEvent”
src=”https://mashupserver/mymashup/application”></odin-mashup>
To send events to the WM you use the sendEvent function of the Odin.MashupCtrl class.
Example:
var parameters = [{
“sourceKey”: “CONO”,
“value”: 123
}];
this.sendEvent(“customerList”, “CurrentItemChanged”, parameters);
Here we present you with a list of tools that you might find useful in your own development.
TypeScript
http://www.typescriptlang.org
AngularJS
https://angularjs.org
AngularUI Bootstrap
http://angular-ui.github.io/bootstrap