API DOCS

DOCS & TUTORIALS » API DOCS » xajax_core » xajaxResponse.inc.php » xajaxResponse

Class: xajaxResponse



Collect commands to be sent back to the browser in response to a xajax
request. Commands are encoded and packaged in a format that is acceptable
to the response handler from the javascript library running on the client
side.

Common commands include:
- <xajaxResponse->assign>: Assign a value to an elements property.
- <xajaxResponse->append>: Append a value on to an elements property.
- <xajaxResponse->script>: Execute a portion of javascript code.
- <xajaxResponse->call>: Execute an existing javascript function.
- <xajaxResponse->alert>: Display an alert dialog to the user.

Elements are identified by the value of the HTML id attribute. If you do
not see your updates occuring on the browser side, ensure that you are
using the correct id in your response.

variables

functions

xajaxResponse

function xajaxResponse()

Create and initialize a xajaxResponse object.

setCharacterEncoding

function setCharacterEncoding($sCharacterEncoding)

Overrides the default character encoding (or the one specified in the
constructor) to the specified character encoding.


setOutputEntities

function setOutputEntities($bOutputEntities)

Convert special characters to their HTML equivellent automatically
(only works if the mb_string extension is available).


plugin

function &plugin()

Provides access to registered response plugins. If you are using PHP
4 or 5, pass the plugin name as the first argument, the plugin method
name as the second argument and subsequent arguments (if any) to be
passed along to the plugin.

Optionally, if you use PHP 5, you can pass just the plugin name as the
first argument and the plugin object will be returned. You can then
access the methods of the plugin directly.


confirmCommands

function confirmCommands($iCmdNumber, $sMessage)

Response command that prompts user with [ok] [cancel] style
message box. If the user clicks cancel, the specified
number of response commands following this one, will be
skipped.


assign

function assign($sTarget,$sAttribute,$sData)

Response command indicating that the specified value should be
assigned to the given element's attribute.


append

function append($sOutput)

Response command that indicates the specified data should be appended
to the given element's property.


prepend

function prepend($sTarget,$sAttribute,$sData)

Response command to prepend the specified value onto the given
element's property.


replace

function replace($sTarget,$sAttribute,$sSearch,$sData)

Replace a specified value with another value within the given
element's property.


clear

function clear()

Response command used to clear the specified property of the
given element.


contextAssign

function contextAssign($sAttribute, $sData)
Response command used to assign a value to a member of a
javascript object (or element) that is specified by the context
member of the request. The object is referenced using the 'this' keyword
in the sAttribute parameter.


contextAppend

function contextAppend($sAttribute, $sData)
Response command used to append a value onto the specified member
of the javascript context object (or element) specified by the context
member of the request. The object is referenced using the 'this' keyword
in the sAttribute parameter.


contextPrepend

function contextPrepend($sAttribute, $sData)
Response command used to prepend the speicified data to the given
member of the current javascript object specified by context in the
current request. The object is access via the 'this' keyword in the
sAttribute parameter.


contextClear

function contextClear($sAttribute)
Response command used to clear the value of the property specified
in the sAttribute parameter. The member is access via the 'this'
keyword and can be used to update a javascript object specified
by context in the request parameters.


alert

function alert($sMsg)

Response command that is used to display an alert message to the user.


redirect

function redirect($sURL, $iDelay=0)

Response command that causes the browser to navigate to the specified
URL.


script

function script($sJS)

Response command that is used to execute a portion of javascript on
the browser. The script runs in it's own context, so variables declared
locally, using the 'var' keyword, will no longer be available after the
call. To construct a variable that will be accessable globally, even
after the script has executed, leave off the 'var' keyword.


call

function call()

Response command that indicates that the specified javascript
function should be called with the given (optional) parameters.


remove

function remove($sTarget)

Response command used to remove an element from the document.


create

function create($sParent, $sTag, $sId, $sType=null)

Response command used to create a new element on the browser.


insert

function insert($sBefore, $sTag, $sId)

Response command used to insert a new element just prior to the specified
element.


insertAfter

function insertAfter($sAfter, $sTag, $sId)

Response command used to insert a new element after the specified
one.


createInput

function createInput($sParent, $sType, $sName, $sId)

Response command used to create an input element on the browser.


insertInput

function insertInput($sBefore, $sType, $sName, $sId)

Response command used to insert a new input element preceeding the
specified element.


insertInputAfter

function insertInputAfter($sAfter, $sType, $sName, $sId)

Response command used to insert a new input element after the
specified element.


setEvent

function setEvent($sTarget,$sEvent,$sScript)

Response command used to set an event handler on the browser.


addHandler

function addHandler($sTarget,$sEvent,$sHandler)

Response command used to install an event handler on the specified element.


removeHandler

function removeHandler($sTarget,$sEvent,$sHandler)

Response command used to remove an event handler from an element.


setFunction

function setFunction($sFunction, $sArgs, $sScript)

Response command used to construct a javascript function on the browser.


wrapFunction

function wrapFunction($sFunction, $sArgs, $aScripts, $sReturnValueVariable)

Response command used to construct a wrapper function around
and existing javascript function on the browser.


includeScript

function includeScript($sFileName, $sType = null, $sId = null)

Response command used to load a javascript file on the browser.


includeScriptOnce

function includeScriptOnce($sFileName, $sType = null, $sId = null)

Response command used to include a javascript file on the browser
if it has not already been loaded.


removeScript

function removeScript($sFileName, $sUnload = '')

Response command used to remove a SCRIPT reference to a javascript
file on the browser. Optionally, you can call a javascript function
just prior to the file being unloaded (for cleanup).


includeCSS

function includeCSS($sFileName, $sMedia = null)

Response command used to include a LINK reference to
the specified CSS file on the browser. This will cause the
browser to load and apply the style sheet.


removeCSS

function removeCSS($sFileName, $sMedia = null)

Response command used to remove a LINK reference to
a CSS file on the browser. This causes the browser to
unload the style sheet, effectively removing the style
changes it caused.


waitForCSS

function waitForCSS($iTimeout = 600)

Response command instructing xajax to pause while the CSS
files are loaded. The browser is not typically a multi-threading
application, with regards to javascript code. Therefore, the
CSS files included or removed with includeCSS> and
removeCSS> respectively, will not be loaded or
removed until the browser regains control from the script. This
command returns control back to the browser and pauses the execution
of the response until the CSS files, included previously, are
loaded.


waitFor

function waitFor($script, $tenths)

Response command instructing xajax to delay execution of the response
commands until a specified condition is met. Note, this returns control
to the browser, so that other script operations can execute. xajax
will continue to monitor the specified condition and, when it evaulates
to true, will continue processing response commands.


sleep

function sleep($tenths)

Response command which instructs xajax to pause execution
of the response commands, returning control to the browser
so it can perform other commands asynchronously. After
the specified delay, xajax will continue execution of the
response commands.


setReturnValue

function setReturnValue($value)

Stores a value that will be passed back as part of the response.
When making synchronous requests, the calling javascript can
obtain this value immediately as the return value of the
function.


getContentType

function getContentType()

Returns the current content type that will be used for the
response packet. (typically: "text/xml")


getOutput

function getOutput()

printOutput

function printOutput()

Prints the output, generated from the commands added to the response,
that will be sent to the browser.


getCommandCount

function getCommandCount()

loadCommands

function loadCommands($mCommands, $bBefore=false)

Merges the response commands from the specified
object with the response commands in this object.


addPluginCommand

function addPluginCommand($objPlugin, $aAttributes, $mData)

Adds a response command that is generated by a plugin.


addCommand

function addCommand($aAttributes, $mData)

Add a response command to the array of commands that will
be sent to the browser.


addEvent

function addEvent($sTarget,$sEvent,$sScript)

Response command used to set an event handler on the browser.


 



XAJAX on SourceForge.net
Support this project Valid XHTML 1.0 Transitional