Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning
titleDeprecated

MVC UI is deprecated from Blueriq 11.0. The alternative for the MVC UI support is to only use the UI REST API  endpoints.


A custom MVC UI theme can be created if the use of default Blueriq themes is not desired. This could be the case if for example you want to create your own client application and Extending themes is not sufficient.

Introduction

The MVC UI has two default themes (Forms theme and Dashboard theme) and bootstrap3 and bootcards) and has support for custom made themes. A theme is basically a set of files and some configuration that consists of the following components:

...


DescriptionLocation
Index fileStringTemplate index file

JAR or

Include Page
_

HomeFolder

ConfigLocation
_

HomeFolder

ConfigLocation

Web resourcesJavaScript, CSS, images, etc.

JAR or

Include Page
_

HomeFolder

ConfigLocation
_

HomeFolder

ConfigLocation

Configuration

Properties in the

aquima.properties file

Include Page
_

HomeFolder

PropertiesFileJava
_

HomeFolder

...

PropertiesFileJava
file

Include Page
_

...

ConfigLocation
_

...

ConfigLocation

...

Getting started

The base of a theme is the index file from which the main page is buildbuilt. Blueriq uses a template engine called StringTemplate to  to make server properties available in the client.

A default Blueriq index page is injected with a template context that features the following properties:

Property
Variable TypeDescription
theme
context.sessionId
String
string
Name
Blueriq Session ID of the
theme currently selectedapiBasePathStringBase path for the web APIwebResourcesBasePathStringBase path for web resourcesextensionsObject (ExtensionContext)Contains all registered CSS and JavaScript files cssExtensionUrlsString[]URLs to all registered CSS files jsExtensionUrlsString[]URLs to all registered JavaScript filessessionIdStringCurrent session idcurrentPageJsonStringCurrent page in JSON formatdevelopmentModebooleanIndicates whether or not the application runs in development modesessionTimeoutintConfigured session timeout in seconds

When creating a custom theme you need to provide a StringTemplate index file.

current Blueriq session
context.theme
string
Current theme of the Blueriq session
context.webResourcesBasePath
string

Location from root where web-resources are located

context.apiBasePath
string

Relative path of API endpoints, always "../api/"

context.currentPage
{ [elementKey: string]: Element }
Full pageModel, see REST Page Models
context.developmentMode
boolean
Indicates if developmentMode is active or not
context.sessionTimeout
integer
Session timeout in seconds

Creating the index file

The index file is the starting point of a custom theme and is a StringTemplate template that follows a certain structure. For full details on the StringTemplate syntax and usage please check the official official documentation. The purpose of the initial page is to load all the required resources (e.g. JavaScript or CSS files) and to provide a base layout.

...

First the delimiters to use around StringTemplate variables are set to "$" instead of the default "<" ">" delimiters to be able to use variables within HTML. StringTemplate uses a function call to generate the template: main(context). The context object that is passed with this function call contains all properties as described above. In the function body (between "<<" and ">>") the actual index page is placed, which is a full HTML page.

...

Save the custom index file as a .stg file  file so it is recognized by StringTemplate.

...

Installing your custom theme is easily done by putting all files in the 

Include Page
_HomeFolderConfigLocation
_HomeFolderConfigLocation
 folder. For example when a theme is created named "custom_dashboard" which consists of an index file, a JavaScript file and a CSS stylesheet, installation would be as follows:

Java

  1. Create a UI/mvc folder in  folder in 
    Include Page
    _HomeFolderConfigLocation
    _HomeFolderConfigLocation
     and put the custom index file (for example example custom_dashboard.stg) here.
  2. Create a webresources/mvc folder in 
    Include Page
    _HomeFolderConfigLocation
    _HomeFolderConfigLocation
     and put the JavaScript and CSS files here (optionally in /js and  and /css subfolders sub folders).
  3. Add a configuration section for your custom theme to aquima.properties in to 
    Include Page
    _HomeFolderPropertiesFileJava
    _HomeFolder
     root, as described in the Configuration section below.

.NET

  1. PropertiesFileJava
     in 
    Include Page
    _ConfigLocation
    _ConfigLocation
     root
  2. Create a UI/mvc folder in the Configuration folder in the .NET webapp installation and put the custom index file (for example custom_dashboard.stg) here.
  3. Create a webresources/mvc folder in the Configuration folder and put the JavaScript and CSS files here (optionally in /js and /css subfolders).
  4. Add a configuration section for your custom theme to Web.config in the wwwroot folder, as described in the Configuration section below.

Configuration

In order to configure your theme so it will be known by the Runtime several properties must be set. The following example shows properties for registering a theme named "custom_dashboard" in both Java and .NET:

...

Code Block
languagetext
titleProperties for registering a custom theme in Java
blueriq.mvc.themes=custom_dashboard
blueriq.mvc.custom_dashboard.templateGroupFile=UI/mvc/custom_dashboard.stg
blueriq.mvc.custom_dashboard.templateName=main
Info

Working with multiple themes is possible by adding comma separated theme names to the mvc.themes property.

.NET

Code Block
languagetext
titleProperties for registering a custom theme in .NET
 <ui> <mvc developmentMode="false"> <themes> <theme name="custom_dashboard" templateGroupFile="UI/mvc/custom_dashboard

.

stg" templateName="main"/> </themes> </mvc> </ui>


The mvc.themes or  or name property specifies the name for the theme which will be displayed in the Runtime theme selector. The other two properties specify which StringTemplate index file should be used and which StringTemplate function should be called to render the index page (see "Creating the index file" above). The path to the index file is relative to either the JAR/DLL or the 

Include Page
_
HomeFolder
ConfigLocation
_
HomeFolder
ConfigLocation
/Configuration folder. When a filename file name is specified which is located in in 
Include Page
_
HomeFolder
ConfigLocation
_
HomeFolder
ConfigLocation
/Configuration and that is already loaded from a JAR, the file from 
Include Page
_
HomeFolder
ConfigLocation
_
HomeFolder
ConfigLocation
/Configuration will be used and the file from the JAR/DLL will be overridden. More information about overriding existing themes can be found on Extending themes.