xajax
[ class tree: xajax ] [ index: xajax ] [ all elements ]

Class: xajaxResponse

Source Location: /pem-includes/xajax/xajax_core/xajaxResponse.inc.php

Class Overview


The xajaxResponse class is used to create responses to be sent back to your Web page. A response contains one or more command messages for updating your page.


Variables

Methods


Child classes:

legacyXajaxResponse
The xajaxResponse class is used to create responses to be sent back to your Web page. A response contains one or more command messages for updating your page.

Class Details

[line 54]
The xajaxResponse class is used to create responses to be sent back to your Web page. A response contains one or more command messages for updating your page.

Currently xajax supports 23 kinds of command messages, including some common ones such as:

  • Assign - sets the specified attribute of an element in your page
  • Append - appends data to the end of the specified attribute of an element in your page
  • Prepend - prepends data to the beginning of the specified attribute of an element in your page
  • Replace - searches for and replaces data in the specified attribute of an element in your page
  • Script - runs the supplied JavaScript code
  • Alert - shows an alert box with the supplied message text

Note: elements are identified by their HTML id, so if you don't see your browser HTML display changing from the request, make sure you're using the right id names in your response.




[ Top ]


Class Variables

$aCommands =

[line 62]



Tags:

var:  internal command storage
access:  protected

Type:   array


[ Top ]

$bOutputEntities =

[line 71]



Tags:

var:  if special characters in the XML should be converted to entities
access:  protected

Type:   boolean


[ Top ]

$returnValue =

[line 77]



Tags:

var:  || array) the value to be passed back as part of the response (if used... only valid for synchronous calls)
access:  protected

Type:   (string


[ Top ]

$sEncoding =

[line 66]



Tags:

var:  the encoding type to use
access:  protected

Type:   string


[ Top ]



Class Methods


constructor xajaxResponse [line 94]

xajaxResponse xajaxResponse( [string $sEncoding = XAJAX_DEFAULT_CHAR_ENCODING], [boolean $bOutputEntities = false])

The constructor's main job is to set the character encoding for the response.

Note: to change the character encoding for all of the responses, set the XAJAX_DEFAULT_ENCODING constant before you instantiate xajax.




Parameters:

string   $sEncoding   contains the character encoding string to use
boolean   $bOutputEntities   lets you set if you want special characters in the output converted to HTML entities

[ Top ]

method addCommand [line 800]

void addCommand( array $aAttributes, mixed $mData)

Adds a commmand to the array of all commands



Parameters:

array   $aAttributes   associative array of attributes
mixed   $mData   data

[ Top ]

method addEvent [line 486]

void addEvent( string $sTarget, string $sEvent, string $sScript)

Adds an event command message to the response.

Usage: $objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sEvent   the event you wish to set ("onclick", "onmouseover", etc.)
string   $sScript   the Javascript string you want the event to invoke

[ Top ]

method addHandler [line 502]

void addHandler( string $sTarget, string $sEvent, string $sHandler)

Adds a handler command message to the response.

Usage: $objResponse->addHandler("contentDiv", "onclick", "content_click");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sEvent   the event you wish to set ("onclick", "onmouseover", etc.)
string   $sHandler   the name of a Javascript function that will handle the event. Multiple handlers can be added for the same event

[ Top ]

method addPluginCommand [line 731]

void addPluginCommand( xajaxResponsePlugin $objPlugin, array $aAttributes, mixed $mData)

Used internally by the response plugin system



Parameters:

xajaxResponsePlugin   $objPlugin   response plugin (subclass of xajaxResponsePlugin)
array   $aAttributes   associative array of command attributes
mixed   $mData   command data

[ Top ]

method alert [line 270]

void alert( string $sMsg)

Adds an alert command message to the response.

Usage: $objResponse->alert("This is important information");




Parameters:

string   $sMsg   the text to be displayed in the Javascript alert box

[ Top ]

method append [line 205]

void append( string $sTarget, string $sAttribute, string $sData)

Adds an append command message to the response.

Usage: $objResponse->append("contentDiv", "innerHTML", "Some New Text");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sAttribute   the part of the element you wish to modify ("innerHTML", "value", etc.)
string   $sData   the data you want to append to the end of the attribute

[ Top ]

method assign [line 189]

void assign( string $sTarget, string $sAttribute, string $sData)

Adds an assign command message to the response.

Usage: $objResponse->assign("contentDiv", "innerHTML", "Some Text");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sAttribute   the part of the element you wish to modify ("innerHTML", "value", etc.)
string   $sData   the data you want to set the attribute to

[ Top ]

method call [line 345]

void call( string $sFunc, mixed $args,...)

Adds a Javascript function call command message to the response.

Usage: $objResponse->call("myJSFunction", "arg 1", "arg 2", 12345);




Parameters:

string   $sFunc   the name of a Javascript function
mixed   $args,...   optional arguments to pass to the Javascript function

[ Top ]

method clear [line 257]

void clear( string $sTarget, string $sAttribute)

Adds a clear command message to the response.

Usage: $objResponse->clear("contentDiv", "innerHTML");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sAttribute   the part of the element you wish to clear ("innerHTML", "value", etc.)

[ Top ]

method confirmCommands [line 173]

void confirmCommands( integer $iCmdNumber, string $sMessage)

Adds a confirm commands command message to the response.

Usage: $objResponse->confirmCommands(1, "Do you want to preview the new data?");




Parameters:

integer   $iCmdNumber   the number of commands to skip if the user presses Cancel in the browsers's confirm dialog
string   $sMessage   the message to show in the browser's confirm dialog

[ Top ]

method create [line 377]

void create( string $sParent, string $sTag, string $sId, [string $sType = ''])

Adds a create element command message to the response.

Usage: $objResponse->create("parentDiv", "h3", "myid");




Parameters:

string   $sParent   contains the id of an HTML element to to which the new element will be appended.
string   $sTag   the tag to be added
string   $sId   the id to be assigned to the new element
string   $sType   deprecated, use the addCreateInput() method instead

[ Top ]

method createInput [line 433]

void createInput( string $sParent, string $sType, string $sName, string $sId)

Adds a create input command message to the response.

Usage: $objResponse->createInput("form1", "text", "username", "input1");




Parameters:

string   $sParent   contains the id of an HTML element to which the new input will be appended
string   $sType   the type of input to be created (text, radio, checkbox, etc.)
string   $sName   the name to be assigned to the new input and the variable name when it is submitted
string   $sId   the id to be assigned to the new input

[ Top ]

method getCommandCount [line 684]

integer getCommandCount( )

Returns the number of commands current in the response



[ Top ]

method getContentType [line 629]

string getContentType( )

Returns the content type of the response (typically "text/xml").



[ Top ]

method getOutput [line 640]

string getOutput( )

Returns the output of the response suitable for sending to a Web browser (i. e., XML or JSON)



[ Top ]

method includeCSS [line 572]

void includeCSS( string $sFileName)

Adds an include CSS command message to the response.

Usage: $objResponse->includeCSS("stylesheet.css");




Parameters:

string   $sFileName   URL of the CSS file to include

[ Top ]

method includeScript [line 532]

void includeScript( string $sFileName)

Adds an include script command message to the response.

Usage: $objResponse->includeScript("functions.js");




Parameters:

string   $sFileName   URL of the Javascript file to include

[ Top ]

method includeScriptOnce [line 545]

void includeScriptOnce( string $sFileName)

Adds an include script once command message to the response.

Usage: $objResponse->includeScriptOnce("functions2.js");




Parameters:

string   $sFileName   URL of the Javascript file to include

[ Top ]

method insert [line 398]

void insert( string $sBefore, string $sTag, string $sId)

Adds a insert element command message to the response.

Usage: $objResponse->insert("childDiv", "h3", "myid");




Parameters:

string   $sBefore   contains the id of the child before which the new element will be inserted
string   $sTag   the tag to be added
string   $sId   the id to be assigned to the new element

[ Top ]

method insertAfter [line 414]

void insertAfter( string $sAfter, string $sTag, string $sId)

Adds a insert element command message to the response.

Usage: $objResponse->insertAfter("childDiv", "h3", "myid");




Parameters:

string   $sAfter   contains the id of the child after which the new element will be inserted
string   $sTag   the tag to be added
string   $sId   the id to be assigned to the new element

[ Top ]

method insertInput [line 452]

void insertInput( string $sBefore, string $sType, string $sName, string $sId)

Adds an insert input command message to the response.

Usage: $objResponse->insertInput("input5", "text", "username", "input1");




Parameters:

string   $sBefore   contains the id of the child before which the new element will be inserted
string   $sType   the type of input to be created (text, radio, checkbox, etc.)
string   $sName   the name to be assigned to the new input and the variable name when it is submitted
string   $sId   the id to be assigned to the new input

[ Top ]

method insertInputAfter [line 471]

void insertInputAfter( string $sAfter, string $sType, string $sName, string $sId)

Adds an insert input command message to the response.

Usage: $objResponse->insertInputAfter("input7", "text", "email", "input2");




Parameters:

string   $sAfter   contains the id of the child after which the new element will be inserted
string   $sType   the type of input to be created (text, radio, checkbox, etc.)
string   $sName   the name to be assigned to the new input and the variable name when it is submitted
string   $sId   the id to be assigned to the new input

[ Top ]

method loadCommands [line 700]

void loadCommands( mixed $mCommands, [ $bBefore = false])

Adds the commands of the provided response to this response object

Usage:

  1. $objResponse2->loadCommands($objResponse1);
  2.  return $objResponse2;




Parameters:

mixed   $mCommands   the response object to add to the end of this response object, or an array of response commands
   $bBefore  

[ Top ]

method plugin [line 137]

void &plugin( string $sName)

Provides access to the xajaxResponse plugin system. If you use PHP 4 or 5, pass the plugin name as the first argument, the plugin's method name as the second argument, and subsequent arguments (if any) after that.

Optionally, if you use PHP 5, you can pass just the plugin name as the first argument and the plugin object will be returned which you can use to call the appropriate method.




Parameters:

string   $sName   name of the plugin to call

[ Top ]

method prepend [line 222]

void prepend( string $sTarget, string $sAttribute, string $sData)

Adds an prepend command message to the response.

Usage: $objResponse->prepend("contentDiv", "innerHTML", "Some Starting Text");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sAttribute   the part of the element you wish to modify ("innerHTML", "value", etc.)
string   $sData   the data you want to prepend to the beginning of the attribute

[ Top ]

method redirect [line 283]

void redirect( string $sURL, [ $iDelay = 0])

Uses the addScript() method to add a Javascript redirect to another URL.

Usage: $objResponse->redirect("http://www.xajaxproject.org");




Parameters:

string   $sURL   the URL to redirect the client browser to
   $iDelay  

[ Top ]

method remove [line 360]

void remove( string $sTarget)

Adds a remove element command message to the response.

Usage: $objResponse->remove("Div2");




Parameters:

string   $sTarget   contains the id of an HTML element to be removed

[ Top ]

method removeCSS [line 585]

void removeCSS( string $sFileName)

Adds a remove CSS command message to the response.

Usage: $objResponse->removeCSS("stylesheet.css");




Parameters:

string   $sFileName   URL of the CSS file to include

[ Top ]

method removeHandler [line 519]

void removeHandler( string $sTarget, string $sEvent, string $sHandler)

Adds a remove handler command message to the response.

Usage: $objResponse->removeHandler("contentDiv", "onclick", "content_click");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sEvent   the event you wish to remove ("onclick", "onmouseover", etc.)
string   $sHandler   the name of a Javascript handler function that you want to remove

[ Top ]

method removeScript [line 560]

void removeScript( string $sFileName, [string $sUnload = ''])

Removes a script reference so the browser can unload the .js file

Usage: $objResponse->removeScript("functions2.js");




Parameters:

string   $sFileName   URL of the Javascript file to remove
string   $sUnload   (optional) script to run before removing reference if it exists (can be used to call an unload function)

[ Top ]

method replace [line 240]

void replace( string $sTarget, string $sAttribute, string $sSearch, string $sData)

Adds a replace command message to the response.

Usage: $objResponse->replace("contentDiv", "innerHTML", "text", "<b>text</b>");




Parameters:

string   $sTarget   contains the id of an HTML element
string   $sAttribute   the part of the element you wish to modify ("innerHTML", "value", etc.)
string   $sSearch   the string to search for
string   $sData   the string to replace the search string when found in the attribute

[ Top ]

method script [line 331]

void script( string $sJS)

Adds a Javascript command message to the response.

Usage: $objResponse->script("var x = prompt('get some text');");




Parameters:

string   $sJS   contains Javascript code to be executed

[ Top ]

method setCharEncoding [line 110]

void setCharEncoding( string $sEncoding)

Sets the character encoding for the response based on $sEncoding, which

is a string containing the character encoding to use. You don't need to use this method normally, since the character encoding for the response gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING constant.




Parameters:

string   $sEncoding  

[ Top ]

method setOutputEntities [line 121]

void setOutputEntities( $bOption)

If true, tells the response object to convert special characters to HTML entities automatically (only works if the mb_string extension is available).



Parameters:

   $bOption  

[ Top ]

method setReturnValue [line 620]

void setReturnValue( $value)

Stores a value (or array) that will be passed back as part of the response.



Parameters:

   $value  

[ Top ]

method waitFor [line 611]

void waitFor( string $script)

Adds a wait for command message to the response

Usage: $objResponse->waitFor('myVariable == "myValue"');




Parameters:

string   $script   Javascript segment which returns a boolean value when evaluated.

[ Top ]

method waitForCSS [line 597]

void waitForCSS( )

Adds a wait For CSS command message to the response.

Usage: $objResponse->waitForCSS();




[ Top ]

method _getReturnValue [line 670]

void _getReturnValue( )

returns an xml encoded string containing the return value to send

back as part of the response, if a return value was set, otherwise and empty string




[ Top ]

method __get [line 159]

void __get( string $sPluginName)

Internal function for PHP5 only. Used to permit plugins to be called as if they were native member variables of the xajaxResponse class.

PHP5 Usage: $objResponse->myPlugin->myPluginMethod("param1", "param2");




Parameters:

string   $sPluginName   The name of the callName of a responsePlugin that has been registered with the plugin manager

[ Top ]


Documentation generated on Tue, 21 Aug 2007 14:49:59 -0500 by phpDocumentor 1.4.0a2