xajax 0.5 Beta 1 review

Download
by rbytes.net on

xajax project is an open source PHP class library for easily creating powerful PHP-driven, web-based AJAX Applications

License: GPL (GNU General Public License)
File size: 0K
Developer: J. Max Wilson
0 stars award from rbytes.net

xajax project is an open source PHP class library for easily creating powerful PHP-driven, web-based AJAX Applications. Using xajax, you can asynchronously call PHP functions and update the content of your webpage without reloading the page.

xajax is designed to be easy to implement. To keep the presentation markup relatively clean and avoid having to create a lot of JavaScript functions to update your web content, xajax allows you to control a great deal of your content through XML responses from your PHP functions.

The xajax class creates javascript wrappers for specified PHP functions and generates the necessary javascript support functions to permit you to call them asynchronously through XMLHttpRequest from any HTML event, such as onclick.

xajax's real power lies in the way it allows you to communicate with and manipulate your application through commands sent back from the server. There is no need to create a multitude of javascript handlers or callback functions to handle the data returned from asynchronous requests. The javascript generated by xajax includes a message-pump, of sorts, that parses XML responses returned from your PHP functions and executes the commands contained therein. A single XML response can contain any number of commands.

The xajax library includes an easy-to-use class to make creating these XML responses extremely easy. The xajax XML Response commands currently available include Assignment, Prepend, Append, Search and Replace, Alert, and custom Javascript commands. For example, let's say that a user clicks on a button in your AJAX application. The onclick event calls the javascript wrapper for a PHP function. That wrapper sends an asynchronous request to the server through XMLHttpRequest that calls the PHP function. The PHP function does a database lookup. You use the xajaxResponse class to generate XML commands to send back to the xajax message pump in your application:

$objResponse = new xajaxResponse();
$objResponse.addAssign("myInput1","value",$DataFromDatabase);
$objResponse.addAppend("myDiv1","innerHTML",$DataFromDatabase2);
$objResponse.addPrepend("myDiv2","innerHTML",$DataFromDatabase3);
$objResponse.addReplace("myDiv3","innerHTML","xajax","xajax");
$objResponse.addScript("var x = prompt("Enter Your Name");");

return $objResponse->getXML();

The xajax message pump would parse the XML message and perform the following:

1. The value of the element with id myInput1 would be assigned to the data in $DataFromDatabase.
2. The data in $DataFromDatabase2 would be appended to the innerHTML of the element with id myDiv1.
3. The data in $DataFromDatabase3 would be prepended to the innerHTML of the element with id myDiv2.
4. All occurrences of "xajax" in the innerHTML of the element with id myDiv3 would be replaced with "xajax"; making all of the instances of the word xajax appear bold.
5. a prompt would be displayed asking for the user's name and the value returned from the prompt would be placed into a javascript variable named x.

All of this is implemented on the server side in the PHP function by forming and returning an xajax XML response. The presentation markup remains remarkably clean because you don't have to create a bunch of callback handlers for your asynchronous requests.

At the same time, xajax is designed to be extremely flexible and leave you, the programmer, in control.

As of version 0.1 beta, all of the data passed through xajax is UTF-8 encoded to support I?t?rn?ti?n?liz?ti?n and you can specify which request method (POST/GET) is to be used to call each individual PHP function through xajax. The default method is POST.

What's New in 0.2.4 Stable Release:
New functionality to permit calling Javascript functions from PHP and passing PHP variables, arrays, and object properties to the Javascript.
It's kind of like JSON, but employs a custom XML format, and is native to xajax.
This release also fixes various bugs and adds some other minor feature enhancements.

What's New in 0.5 Beta 1 Development Release:
Package-wide changes:

All of the PHP files have been moved to xajax_core, so the PHP and Javascript
files are now in separate folders.
All tests and examples have been updated to work with the new 0.5 API.
A new file, legacy.inc.php, can be included in your PHP scripts if you want
to be able to use the 0.2.4 xajax API. However, it is recommended you update
your scripts to the 0.5 API as soon as possible as the legacy API will likely
be dropped in a future version of xajax.
A new plugin layer has been implemented for the xajax and xajaxResponse
classes. The basis for this is the xajaxPluginManager class which provides
for registering and accessing plugins for the different xajax components.
xajax is now licensed under the BSD license rather than the LGPL license.
This means you can include xajax and modify it when using it with commercial
PHP applications without having to worry about tricky legal issues.

xajax Plugin Layer:

xajax now uses plugins to process requests and output Javascript include
code. You can subclass the default plugins to alter major xajax functionality
or write your own plugins from scratch.
You can use plugins with xajaxResponse, allowing you to output custom
commands to the Web client. (Note: this won't be very useful until the a new
plugin system is implemented in the xajax Javascript engine.)
Plugin layer documentation forthcoming.

xajax.inc.php changes:

The xajax constructor has been simplified to allow only one optional argument
(the request URI).
New getGlobalResponse method lets you use the same response in multiple
functions. It also makes it easier to set up the response to have the same
encoding and entity settings as the xajax parent object.
New getVersion method returns the xajax version.
All of the ___On and ___Off methods have been replaced with a single setFlag
(or setFlags) method. For instance, debugOn() would now be
setFlag("debug", true). exitAllowedOff() would now be
setFlag("exitAllowed", false).
New setTimeout and getTimeout methods for controlling the delay before the
client shows an error alert if the xajax Javascript engine failed to load
(just set to 0 to suppress any error alert).
Registering functions to use only GET or POST for the HTTP connection is no
longer possible. All functions use POST by default, and if for some reason
you need to force using GET, you can use the xajax.call syntax on the
client-side.
The registerFunction method now provides an optional second argument for
specifying a PHP file to include, thereby eliminating the need for the
registerExternalFunction method.
New registerCallableObject method registers an object that xajax will check
to see if it contains a method with the same name as the incoming xajax
function. If it finds one, it will go ahead and call that method as if it had
been manually registered with xajax (and in PHP 5, it will _always_ go ahead
with the method call if a __call magic method is present).
The registerPreFunction and registerCatchAllFunction methods have been
eliminated and replaced with the new registerEvent method. You can register
one or more functions or class/object methods to be notified when certain
events in the xajax lifecycle are triggered. The "pre function" is now the
"beforeProcessing" event. The "catch all function" is now the
"onMissingFunction" event.
The canProcessRequests and processRequests methods are now singular (i.e.,
canProcessRequest and processRequest).
All of the following methods use an xajaxRequestProcessorPlugin subclass
(typically xajaxDefaultRequestProcessorPlugin) to perform all neccessary
work:
canProcessRequest
getProcessMode
processRequest
All of the following methods use an xajaxIncludePlugin subclass (typically
xajaxDefaultIncludePlugin) to perform all necessary work:
printJavascript
getJavascript
getJavascriptConfig
getJavascriptInclude

xajaxResponse.inc.php changes:

All method names for adding commands have had their "add" prefixes removed
(though of course addEvent and addHandler remain). In other words, addAssign
is now just assign, addScript is now just script, etc. In addition, all
of the command methods return $this (the xajaxResponse object) to allow for
"fluent interface" usage in PHP 5.
Internally all of the commands are stored as array-based data structures and
are only converted to XML upon final output. Several new methods allow for
adding command data manually and merging commands from other response
objects. Much of this functionality is extremely useful for response plugins.
As part of the new xajax plugin layer, response object plugins that were
registered with the plugin manager can be accessed either via the plugin
method on PHP 4 and 5 (with two different call types) or as properties via
the __get magic method in PHP 5.
New includeScriptOnce and includeCSS commands available.
IMPORTANT: you may no longer return the getXML() method output as your return
value in registered xajax functions. Please return the response object
directly.

xajax_uncompressed.js Javascript changes:

The Javascript engine for xajax has been substantially rewritten and is still
undergoing major changes. Note that some of the changes are "reversed" when
using the xajax legacy PHP class (specifically xajax.call,
xajax.loadingFunction, and xajax.doneLoadingFunction work the same as
before).
xajax.call now supports only two arguments, the first being the function name
to call on the server and the second being a Javascript dictionary-style
object you can use to specify parameters, event callbacks, and other options
(in a manner reminiscent of Prototype).
xajax.loadingFunction and xajax.doneLoadingFunction have been replaced by
xajax.eventFunctions.globalRequestDelay and
xajax.eventFunctions.globalRequestComplete (though in most cases it is
recommended that you make use of the per-call event callbacks mentioned
above).
Instead of expecting options set by the xajax include code such as
xajaxRequestUri or xajaxDebug, the Javascript engine now expects an
xajaxConfig object to be present in the global namespace with properties
such as requestURI and debug.
The xajax Javascript object is now written using brackets syntax ala
Prototype and many other modern Javascript libraries.

xajax 0.5 Beta 1 keywords