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

Class: xajaxResponse

Source Location: /vendors/xajax/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



Class Details

[line 68]
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 21 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 76]



Tags:

var:  internal command storage
access:  protected

Type:   array


[ Top ]

$bOutputEntities =

[line 89]



Tags:

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

Type:   boolean


[ Top ]

$sEncoding =

[line 84]



Tags:

var:  the encoding type to use
access:  protected

Type:   string


[ Top ]

$xml =

[line 80]



Tags:

var:  internal XML storage
access:  protected

Type:   string


[ Top ]



Class Methods


constructor xajaxResponse [line 106]

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 addAlert [line 292]

void addAlert( string $sMsg)

Adds an alert command message to the XML response.

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




Parameters:

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

[ Top ]

method addAppend [line 207]

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

Adds an append command message to the XML response.

Usage: $objResponse->addAppend("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 addAssign [line 186]

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

Adds an assign command message to the XML response.

Usage: $objResponse->addAssign("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 addClear [line 274]

void addClear( string $sTarget, string $sAttribute)

Adds a clear command message to the XML response.

Usage: $objResponse->addClear("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 addCommand [line 795]

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 addConfirmCommands [line 165]

void addConfirmCommands( integer $iCmdNumber, string $sMessage)

Adds a confirm commands command message to the XML response.

Usage: $objResponse->addConfirmCommands(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 addCreate [line 426]

void addCreate( string $sParent, string $sTag, string $sId, [string $sType = ""])

Adds a create element command message to the XML response.

Usage: $objResponse->addCreate("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 addCreateInput [line 497]

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

Adds a create input command message to the XML response.

Usage: $objResponse->addCreateInput("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 addEvent [line 565]

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

Adds an event command message to the XML 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 581]

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

Adds a handler command message to the XML 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 addIncludeScript [line 616]

void addIncludeScript( string $sFileName)

Adds an include script command message to the XML response.

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




Parameters:

string   $sFileName   URL of the Javascript file to include

[ Top ]

method addInsert [line 452]

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

Adds a insert element command message to the XML response.

Usage: $objResponse->addInsert("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 addInsertAfter [line 473]

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

Adds a insert element command message to the XML response.

Usage: $objResponse->addInsertAfter("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 addInsertInput [line 521]

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

Adds an insert input command message to the XML response.

Usage: $objResponse->addInsertInput("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 addInsertInputAfter [line 545]

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

Adds an insert input command message to the XML response.

Usage: $objResponse->addInsertInputAfter("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 addPrepend [line 229]

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

Adds an prepend command message to the XML response.

Usage: $objResponse->addPrepend("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 addRedirect [line 310]

void addRedirect( 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 addRemove [line 404]

void addRemove( string $sTarget)

Adds a remove element command message to the XML response.

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




Parameters:

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

[ Top ]

method addRemoveHandler [line 598]

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

Adds a remove handler command message to the XML response.

Usage: $objResponse->addRemoveHandler("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 addReplace [line 252]

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

Adds a replace command message to the XML response.

Usage: $objResponse->addReplace("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 addScript [line 363]

void addScript( string $sJS)

Adds a Javascript command message to the XML response.

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




Parameters:

string   $sJS   contains Javascript code to be executed

[ Top ]

method addScriptCall [line 382]

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

Adds a Javascript function call command message to the XML response.

Usage: $objResponse->addScriptCall("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 alert [line 298]

void alert( $sMsg)



Parameters:

   $sMsg  

[ Top ]

method append [line 213]

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



Parameters:

   $sTarget  
   $sAttribute  
   $sData  

[ Top ]

method assign [line 192]

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



Parameters:

   $sTarget  
   $sAttribute  
   $sData  

[ Top ]

method call [line 391]

void call( )



[ Top ]

method clear [line 280]

void clear( $sTarget, $sAttribute)



Parameters:

   $sTarget  
   $sAttribute  

[ Top ]

method confirmCommands [line 171]

void confirmCommands( $iCmdNumber, $sMessage)



Parameters:

   $iCmdNumber  
   $sMessage  

[ Top ]

method create [line 437]

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



Parameters:

   $sParent  
   $sTag  
   $sId  
   $sType  

[ Top ]

method createInput [line 503]

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



Parameters:

   $sParent  
   $sType  
   $sName  
   $sId  

[ Top ]

method getOutput [line 637]

string getOutput( )

Returns the XML to be returned from your function to the xajax processor on your page. Since xajax 0.2, you can also return an xajaxResponse object from your function directly, and xajax will automatically request the XML using this method call.

Usage: return $objResponse->getXML();




Tags:

return:  response XML data


[ Top ]

method getXML [line 662]

void getXML( )



[ Top ]

method includeScript [line 622]

void includeScript( $sFilename)



Parameters:

   $sFilename  

[ Top ]

method insert [line 458]

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



Parameters:

   $sBefore  
   $sTag  
   $sId  

[ Top ]

method insertAfter [line 479]

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



Parameters:

   $sAfter  
   $sTag  
   $sId  

[ Top ]

method insertInput [line 527]

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



Parameters:

   $sBefore  
   $sType  
   $sName  
   $sId  

[ Top ]

method insertInputAfter [line 551]

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



Parameters:

   $sAfter  
   $sType  
   $sName  
   $sId  

[ Top ]

method loadCommands [line 696]

void loadCommands( $mCommands)



Parameters:

   $mCommands  

[ Top ]

method loadXML [line 679]

void loadXML( string $mCommands)

Adds the commands of the provided response XML output to this response object

Usage:

  1. $r1 $objResponse1->getXML();
  2.  $objResponse2->loadXML($r1);
  3.  return $objResponse2->getXML();




Parameters:

string   $mCommands   the response XML (returned from a getXML() method) to add to the end of this response object

[ Top ]

method outputEntitiesOff [line 151]

void outputEntitiesOff( )

Tells the response object to output special characters intact. (default

behavior)




[ Top ]

method outputEntitiesOn [line 142]

void outputEntitiesOn( )

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



[ Top ]

method prepend [line 235]

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



Parameters:

   $sTarget  
   $sAttribute  
   $sData  

[ Top ]

method redirect [line 351]

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



Parameters:

   $sURL  
   $iDelay  

[ Top ]

method remove [line 410]

void remove( $sTarget)



Parameters:

   $sTarget  

[ Top ]

method removeHandler [line 604]

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



Parameters:

   $sTarget  
   $sEvent  
   $sHandler  

[ Top ]

method replace [line 260]

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



Parameters:

   $sTarget  
   $sAttribute  
   $sSearch  
   $sData  

[ Top ]

method script [line 369]

void script( $sJS)



Parameters:

   $sJS  

[ Top ]

method setCharEncoding [line 122]

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 132]

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 ]


Documentation generated on Mon, 05 Sep 2011 20:34:58 -0500 by phpDocumentor 1.4.3