Creating a view (other than a sign-in view)

The sample is an example of a view that replaces the built-in home view with an alternate version that includes branding for the Sample Outdoors Company.

The sample contains a spec.json file that defines the view. This file is shown here.

  "name": "Sample_Welcome",
  "schemaVersion": "2.0",
  "extensions": [{
    "perspective":"Sample welcome",
    "features": [{
      "id": "com.sample.welcome",
      "excludeItems": [""],
      "toolItems": [{
        "id": "brandLogoHomePage",
        "containerId" : "",
        "type": "bi/glass/app/plugins/GlassPlugin",
        "class": "cognosIcon cognosLogo",
        "icon": "theme.current.images.brandIconSmall",
        "weight": 995
      "content": {
        "options": {
            "title":"Sample welcome",
      "cssStyles": [

The view is referred to as Sample welcome in the managing customization panels. The spec.json file links to a SampleWelcomeView.js file in the js/views subfolder of the view. The "type":"home" entry indicates this view can be set to be the default home view. The cssStyles element defines the .css file used when displaying the view.

The SampleWelcomeView.js file is shown here.

 * Licensed Materials - Property of IBM
 * IBM Cognos Products: BI Glass
 * Copyright IBM Corp. 2015
 * US Government Users Restricted Rights - Use, duplication or disclosure restricted 
 * by GSA ADP Schedule Contract with IBM Corp.
  ], function(Q, html) {
  'use strict';

  var ContentView = function(){
     * Called by the AppController whenever this view is created
     * @public
     * @returns {Promise} promise resolved to the root DOM element for this view.
     */ = function(context, options) {
      this.logger = context.logger;
      this.options = options;
      var deferred = Q.defer();
      var root = document.createElement('div');
      root.innerHTML = html;
      return deferred.promise;
     * Called by the AppController whenever this view is destroyed
     * @public
    this.close = function() {'close');
     * Called by the AppController whenever this view is shown
     * @public
    this.onShow = function() {'onShow');
     * Called by the AppController whenever this view is hidden
     * @public
    this.onHide = function() {'onHide');
     * Called by the AppController whenever display Info is required for this view
     * @public
     * @returns {Object} displayInfo - The displayInfo for this view.
     * @returns {string} displayInfo.title - The title.
     * @returns {string} displayInfo.icon - The icon.
    this.getDisplayInfo = function() {'getDisplayInfo');
      return {


  return ContentView;


This file refers to the SampleWelcomeView.html that is displayed when the view is invoked.

This JavaScript code uses the View API in a JavaScript AMD module. This implementation uses the JavaScript Q library. The View API consists of the following methods. methods.

promise open(content. options)
This method is invoked when the view is opened. It returns a Q promise object with the DOM element that represents the view as the resolved value.
Contains the context object.
Contains the options included in the spec.json file.
void close()
Invoked just before closing the view.
void onShow()
Invoked just before showing the view.
void onHide()
Invoked just before hiding the view.
Returns the title and associated icon of the view.