Myna Application.sjs Tutorial

The application.sjs file is used to create global variables, methods, or anything else you want global access to.

You should also use the application.sjs file to operate on the $application object. This way, you know where your application settings are being set.

You can have multiple application.sjs files as well. For example, you can have one in your the root folder of your web app, and also have one in a sub folder. When a script executes, whatever the path of execution, each applications.sjs file will be included which is in the path from the root down to the script.

Here is and example:

//This assigns a propery to the $application object
$application.layoutDir = $application.directory + "layout";

// This sets up a global Page object
var Page={
	includeLayout:true,
	title:"",
	keywords:"",
	breadCrumbs:[{
		url:appUrl,
		label:"Home"
	}],
  breadCrumbsPage:"",
	description:"",
	tags:[]
}

In this application.sjs, we are creating a page object that we can access anywhere in our application. We can also add to this object in other application.sjs files in other sub folders. Powerful, but simple!