Applications

By default, every page belongs to a single Jaxer application: and so the Jaxer.application and Jaxer.session state containers are shared. To change this behavior, create a new application.

Create an Application

You can put application-specific settings in either configApps.js or a separate file as long as the separate file's name ends in .configApps.js (for example, myApp.configApps.js). Both choices produce the same results when the application runs, the reason for choosing one way over the other is mostly down to personal preference and convenience.

This method of application configurations lets you segregate URL patterns, pages, databases, and resource paths within each application.

Jaxer comes with two additional configuration files: aptana.configApps.js and services.configApps.js.

  • aptana.configApps.js: Holds the settings for the sample applications shipped with Jaxer defines somple simple web
  • services.configApps.js: Contains service dispatchers shipped with Jaxer: a generic one for any jaxer-service request, useful for, say, defining RESTful services, and a more specialized one for Remote Procedure Calls that knows to call your JavaScript functions.

Jaxer comes with three config files

FileDescription
configApps.jsShows you how to switch the default DB used for apps or to configure a new app of your own
services.configApps.jsContains default configurations for the two new service dispatchers shipped as samples with Jaxer
aptana.configApps.jsContains configurations for the samples and tools shipped with Jaxer

Here's where to find them (only after the first time you run Jaxer):

ProductLocation
JaxerAptana_Jaxer/local_jaxer/conf/
Aptana StudioAptana_Studio/plugins/com.aptana.jaxer.server/jam/jaxer/framework
Note: configApps.js is never overwritten when upgrading Jaxer.

Each session container belongs to the context of an application. So creating an application will affect the sharing of values within two state contexts: application and session. The sessionPage container is not affected because its session values are private to a single page.

Edit a configApps.js

To add an application, insert or unshift an entry into the Config.apps array. These properties must be included:
PropertyDescription
urlTesta regular expression or function which evaluates to true if the requested URL matches this specified application. Learn more about regular expression patterns.
namethe unique name of this application within Jaxer
appKeyused to identify the Jaxer.application container
pageKeyused to identify the Jaxer.page container
paththe resource path to use for data. The passed argument resolvedName is the same as specified name of this application object
dbthe database configuration to use within this application. The easiest option is use the function smartDB which has been provided in configApps.js
handler[pending: cutting edge]

Each of these properties is available to the application as properties of Jaxer.Request.app, an instance of Jaxer.App. The resolved value of many of these configuration properties may be accessed using uppercase keyed properties of Jaxer.App (PAGE_KEY rather than pageKey).

After modifying configApps.js, Jaxer must be restarted.

Configuration Q&A

How do I suppress the display of revealing Jaxer errors in the browser

Jaxer is shipped configured for a development environment, with server-side exception and error handling turned on.

This means messages generated on the server-side will be sent to the browser for simpler debugging and development cycles. If the error occurred before the final processing of the page, the HTML returned to the browser may well contain server-only code. To prevent such code and detailed error messages from being seen by users in a production environment, we strongly recommend you change the Config.DISPLAY_ERRORS setting in local_jaxer/conf/config.js before going live.

Generate an error that the default configuration displays to the browser

<script runat='server'>
     throw 'foo';
</script>
Default error message

Changing to Config.DISPLAY_ERRORS false replaces the message with a more generic version, though the error information is still added to the application log file.

User-oriented error message

How do I configure Jaxer to use my proxy settings?

Much like any browser can be configured to route its network traffic through a proxy, so too Jaxer supports working with a proxy; in fact it uses the same preferences as Firefox. To see the list of preferences used on your computer, open the special URL about:config in Firefox and filter for network.proxy where you'll find network.proxy.type, network.proxy.http, network.proxy.http_port and several more. The complete list is available on the Mozilla Networking Preferences page. Jaxer's proxy preferences are kept in local_jaxer/conf/config.js.

Generate an error that the default configuration displays to the browser

Config.MOZ_PREFS["network.proxy.type"] = 1; // manual
Config.MOZ_PREFS["network.proxy.http"] = "127.0.0.1";
Config.MOZ_PREFS["network.proxy.http_port"] = 8888;

Configuring a New Application

Configure a new Jaxer application at the path /myapplication/

Configuration Test Page: index.html
Output of /myapplication/index.html
Output of /myapplication/subdirectory/index.html