Detailed reference of prototypes, properties and methods available in the
Javascript environment of your Helma web applications.

Default properties and methods of the app object.
ApplicationBean app
This object is automatically instantiated as the app property of the global object (or global.app) and there is no constructor to instantiate further instances.

The app object is a host object representing the application for which the current scripting environment is provided.

For further details also see the JavaDocs for Packages.helma.framework.core.ApplicationBean. Since that class is a JavaBean all of its get- and set-methods are also directly available as properties of this object.
see
Application app. __app__
This property contains a reference this application's instance of the Packages.helma.framework.core.Application class.

It represents the currently running application, and offers some additional public methods. See Helma's JavaDocs on Packages.helma.framework.core.Application for more information.
see
TransientNode app. data
Object that serves as a cache for application specific data.

This property offers the possibility to store arbitrary data on an application wide level, and is available as long as the application is running.

Note, that this can just be used as a temporary storage (i.e. as a 'cache'), since this data is not stored persistently within Helma, and is lost when the application is restarted. However, unlike global properties, any data stored in this object will not be garbage collected during runtime.

Example:
app.data.runlevel = 4;
app.data.language = "en";
 
res.write(app.data);
TransientNode app
 
for (var p in app.data)
  res.writeln(p + ": " + app.data[p]);
runlevel: 4
language: en
 
res.write(app.data.runlevel);
4
 
res.write(app.data["language"]);
en
see
String[] app. globalMacroPath
The app.globalMacroPath property allows to define a search path for global macros. This is a String array containing a list of global namespaces.
Number app. maxThreads
This property contains the maximum number of additional threads (=request evaluators)

The maximum number of additional threads that are being created by Helma to handle incoming requests. This property is readable and writeable.
see
Map app. modules
Map object that can be used as an application wide data cache

This property offers a dedicated place to store module-related data on an application wide level. Note, that this can just be used as a temporary storage (i.e. as a 'cache'), since this data is not stored persistently within Helma, and is lost when the application is restarted.
see
Map app. properties
Map of any specified application or server properties

This property offers access to each key/value pair defined in either app.properties or in server.properties. These properties are read-only.

To get a Map of apps.properties for this application, use the app.getAppsProperties method instead.

Example:
# File app.properties:
debug = true
color = #ffcc00
 
res.write(app.properties);
{debug=true,color=#ffcc00}
 
for (var p in app.properties)
  res.writeln(p + ": " + app.properties[p]);
debug: true
color: #ffcc00
 
res.write(app.properties.debug);
true
 
res.write(app.properties["color"]);
#ffcc00
see
Function app. processMacroParameter
This allows the application to set a callback function for pre-processing macro parameters formatted as $(...). The function is expected to take the raw parameter value as argument and return the processed parameter.
Array app. repositories
List of the application's code repositories

Returns an array of FileRepository, SingleFileRepository, MultiFileRepository and ZipRepository objects.
see
Methods
app. addRepository(repository, repository)
Adds a code repository to the current application
parameters
String repository as String, the path to the code repository
Repository repository as a Repository object, implementing the Repository interface
see
app. addCronJob(functionName, crontab)
Adds a global function to the list of CronJobs that are being called periodically.

If the property 'schedulerInterval' has not been set otherwise in app.properties, the function will be called every 60 seconds.

By passing along further arguments it is possible to define at what times that function should be called. The same syntax ('*', '1,10,15', '1-5',..) as for Unix' crontab file can be used. Note, that if the property 'schedulerInterval' has been set in app.properties below 60, the function will be called several times in the minute, that it is supposed to run.
parameters
String functionName as String, name of function to be scheduled as cron job
String crontab syntax of comma delimited arguments for year, month, day, weekday, hour, minute
see
app. clearCache()
Removes all objects from the object cache for the current application.

By calling this method it is possible to make sure Helma will fetch all objects fresh from the database.
see
app. countSessions()
Returns the number of currently active sessions.
returns
Number of sessions (integer)
see
app. createSession(String)
Creates a SessionObject with the passed sessionID as its unique identifier.

If a session with that ID already exists, that session will be returned.
parameters
String String of the ID for this session
returns
SessionObject for the specified
see
app. debug(filenameOrText, text)
Writes a string to a log file if debug is set to true in app.properties.

Either the text provided as the first argument is written to the eventLog file or the text that is provided as the second argument is written to a log file who's name is specified as the first argument.

Writing to a file can be overridden by setting the property "logdir" in the server.properties or app.properties file to the value "console".

Example:
# File helma/apps/test/app.properties:
debug = true
 
// File helma/apps/test/root/main.hac:
app.debug("This message is written to the test application's event log.");
app.debug("custom", "This message is written to the custom.log file.");
 
File helma/log/test_event.log:
[2006/07/11 17:08] This message is written to the test application's event log.
 
File helma/log/custom.log:
[2006/07/11 17:08] This message is written to the custom.log file.
parameters
String filenameOrText as String, the log filename to write to or the text to write to the eventLog file
String text as String the text to write, if the filename was specified as the first argument
see
app. getActiveThreads()
Returns the number of currently active threads (=request evaluators).
returns
Number of currently active threads (integer)
see
app. getActiveUsers()
Returns an array of Users, that are currently logged in.
returns
Array of User objects
see
app. getAppDir()
Returns the absolute path to the application directory.

For multiple repositories this is either, the directory specified as 'appdir' in apps.properties, or the first FileRepository occurring in the repository list.
returns
String with the absolut path to the application directory
see
app. getAppsProperties()
Get a wrapper around the app's apps.properties

To get a Map of app.properties and server.properties for this application, use app.properties instead.
returns
a readonly wrapper around the application's apps.properties
see
app. getCacheusage()
Returns the number of currently cached objects for the current application.
returns
Number of cached objects
see
app. getClassLoader()
Returns the app's ClassLoader.
returns
ClassLoader
app. getCronJobs()
Returns an object of scheduled cron jobs.

Returns a JavaScript object with the function names as property names and the Packages.helma.util.CronJob instance as property values.
returns
Object with Packages.helma.util.CronJob properties
see
app. getDir()
Returns the absolute path to the application directory.

For multiple repositories this is either, the directory specified as 'appdir' in apps.properties, or the first FileRepository occurring in the repository list.
returns
String with the absolut path to the application directory
see
app. getErrorCount()
Returns the number of errors that have occurred since the application has been started.
returns
Number of errors (integer)
see
app. getFreeThreads()
Returns the number of currently free threads (i.e. request evaluators).

This is equivalent to app.getMaxThreads() minus app.getActiveThreads().
returns
Number of free threads (integer)
see
app. getLogger(logname)
Returns the app's event logger.

This is a commons-logging Log with the category helma.[appname].event or the specified logname.
parameters
String logname as String, optional log category
returns
Log
see
app. getMaxThreads()
Returns the maximum number of threads (i.e. request evaluators).
returns
Number of threads (integer)
see
app. getName()
Returns the name of the current application, i.e. the name used in apps.properties.
returns
String with application's name
app. getPrototype(name)
Returns a prototype by name.
parameters
String name as String, the prototype name
returns
Prototype
app. getPrototypes()
Returns an array of this app's prototypes
returns
Array containing the app's prototypes
app. getRegisteredUsers()
Returns an array of all existing users.
returns
Array of User objects
see
app. getRequestCount()
Returns the number of web requests that occurred since the application has been started.
returns
Number of web requests served (integer)
see
app. getServerDir()
Returns the absolute path to the home directory of this Helma installation.

If Helma is run in embedded mode, this will be equal to the application directory.
returns
String with absolute path to home directory
see
app. getSession(sessionID)
Returns a SessionObject identified through the passed sessionID, if such a session exists.
parameters
String sessionID as String, the ID of an existing session
returns
SessionObject matching the specified ID or null if there is no matching session
see
app. getSessions()
Returns an array of all currently active sessions, represented as SessionObjects.
returns
Array of SessionObject
see
app. getSessionsForUser(user)
Returns an array of active sessions for the specified user

Returns an array of all currently active sessions, which have been associated with the passed User. Returns an empty array if no User is passed.

Passing a string of the username as argument has been deprecated in favor of passing a User object.
parameters
User user as User object
returns
Array of SessionObject
see
app. getSkin(protoname, skinname, skinpath)
Returns a skin for a given object.

The skin is found by determining the prototype to use for the object, then looking up the skin for the prototype.
parameters
String protoname as String
String skinname as String
Array skinpath as Array, directory paths or HopObjects to search for skins
returns
Skin
app. getSkinfiles()
Returns a Map that allows access to all defined file-based skins.

The map contains for each prototype one entry (for prototypes containing also uppercase letters, also an entry with the lowercased prototype name is contained). This entry contains for each skin file residing in that prototype directory, an entry with the name of the file and the content/source of that file as its value.
returns
Map of SkinMap objects
see
app. getSkinfilesInPath(skinpath)
Return a map of skin resources including the specified, app-specific skinpath

The map contains for each prototype one entry (for prototypes containing also uppercase letters, also an entry with the lowercased prototype name is contained). This entry contains for each skin file residing in that prototype directory, an entry with the name of the file and the content/source of that file as its value.
parameters
Array skinpath as Array, directory paths or HopObjects to search for skins
returns
Map of SkinMap objects
see
app. getUpSince()
Returns the timestamp of when that application has been started.
returns
Date when the application last started
see
app. getUser(username)
Returns a User identified through the passed username.

The prototype User must have a username defined through the '_name'-property in type.properties for this to work.
parameters
String username as String
returns
User object with the specified _name property
see
app. getXmlrpcCount()
Returns the number of XmlRpc requests that occurred since the application has been started.
returns
Number of XmlRpc requests served (integer)
see
app. invoke(thisObject, fnc, args, timeout)
Trigger a synchronous Helma invocation.
parameters
Object thisObject as Object, the object to invoke the function on, or null for global invocation
Function fnc the function or function name to invoke
Array args as Array, optional arguments to be passed to the function fnc
Number timeout as Number, optional amount of milliseconds after which the invocation should be interrupted
returns
the value returned by the function fnc
exceptions
Exception exception thrown by the function
see
app. invokeAsync(thisObject, fnc, args, timeout)
Trigger an asynchronous Helma invocation.

This method returns immedately with an object that allows to track the result of the function invocation with the following methods and properties:
  • running - true while the function is running, false afterwards
  • result - the value returned by the function, if any
  • exception - the exception thrown by the function, if any
  • waitForResult() - wait indefinitely until invocation terminates and return the result
  • waitForResult(t) - wait for the specified number of milliseconds for invocation to terminate and return the result
Setting the timeout to -1 will let the task run forever instead of the default maximum of 15 minutes.
parameters
Object thisObject as Object, the object to invoke the function on, or null for global invocation
Function fnc the function or function name to invoke
Array args as Array, optional arguments to be passed to the function fnc
Number timeout as Number, optional amount of milliseconds after which the invocation should be interrupted
returns
Object with the properties described above
see
app. log(filenameOrText, text)
Writes a string to a log file.

Either the text provided as the first argument is written to the eventLog file or the text that is provided as the second argument is written to a log file who's name is specified as the first argument.

Writing to a file can be overriden by setting the property "logdir" in the server.properties or app.properties file to the value "console".

Example:
app.debug("This message is written to the test application's event log.");
app.debug("custom", "This message is written to the custom.log file.");
 
File helma/log/test_event.log:
[2006/07/11 17:08] This message is written to the test application's event log.
 
File helma/log/custom.log:
[2006/07/11 17:08] This message is written to the custom.log file.
parameters
String filenameOrText as String, the log filename to write to or the text to write to the eventLog file
String text as String the text to write, if the filename was specified as the first argument
see
app. registerUser(username, password)
Creates a new User object

Creates a new HopObject of prototype User, stores it persistently, and returns the created User object.

When mapping the User prototype to a relational database, the type.properties file must contain mappings for the '_name'-property (the username) and for a property named 'password'.
parameters
String username as String
String password as String
returns
User object that was created
see
app. removeCronJob(functionName)
Removes a CronJob, identified through the passed function name, from the list of CronJobs.
parameters
String functionName as String
see
Fri, 05 Feb 2010 17:40:04 GMT.

core framework

optional modules

java libraries

properties files