Evolved features
Namespaces
All classes of the jaxon-core package are now in the Jaxon
namespace. The main class is a singleton, and the unique instance is returned by the jaxon()
function. The URI that was passed to the class constructor in the previous version must now be defined with the core.request.uri
configuration. So this is how to start a Jaxon application.
$jaxon = jaxon();
$jaxon->setOption('core.request.uri', $uri);
Constants
The constants have been renamed and are now all set in the main Jaxon
class. The new name of the constant is obtained by replacing the prefix XAJAX_
by class name Jaxon::
, as in the following example.
$jaxon->register(Jaxon::CALLABLE_OBJECT, $myObject); // In current version
$jaxon->register(XAJAX_CALLABLE_OBJECT, $myObject); // In previous version
As exceptions to this rule, the constants XAJAX_FUNCTION
becomes Jaxon::USER_FUNCTION
and XAJAX_EVENT
becomes Jaxon::BROWSER_EVENT
.
The constant XAJAX_DEFAULT_CHAR_ENCODING
no longer exists; the configuration option core.encoding
must be used instead.
Javascript code generation
The function $jaxon->getJavascript()
which returns the javascript code generated by the library has been separated into three distinct functions:
- The function
$jaxon->getCss()
returns the code which includes external CSS files. - The function
$jaxon->getJs()
returns the code which includes external javascript files. - The function
$jaxon->getScript()
returns the javascript code generated for exported classes and functions.
This separation exists because these codes can be inserted into different parts of the HTML page.
However, by calling $jaxon->getScript(true, true)
, we obtain the cumulative output of these three functions.
Configuration options
The configuration functions and options of the Jaxon library have been renamed.
A call to $jaxon->setOption($name, $value)
is now needed to update an option, while a call to $jaxon->getOption($name)
returns the value of an option. These two functions take the new option names as parameter.
The $jaxon->configure($name, $value)
and $jaxon->getConfiguration($name)
functions can still be used with the old names of options, but they are deprecated in version 1 and removed from version 2.