Quick links: Content - sections - sub sections
EN

Trace: 1.8.x credits 1.5 hall-of-fame erreurs-1.1 download 1.6.x faq 1.4.x 1.1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:tutorial:action-creation [2006/09/25 08:39] doublefaceen:tutorial:action-creation [2007/09/17 22:42] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Creation of an action ====== +deleted
- +
- +
-===== A little bit of theory ===== +
- +
-An action is a fundamental element of the framework. Every display, every form processing, every web service call is an action. +
- +
-An action is called through a request which has a defined type and generates a specific response, in a specific format, which can be linked to the type of the actual request. +
- +
-There are several types of requests, notably the type which is named “classic” in Jelix , for which an action can provide a response in an unspecified format: HTML, XML etc. It is for this type of request that you will generally define actions. In general, this type of request provides its parameters in the URL or the body of HTTP request (POST method). +
- +
-You also have the xmlrpc type requests (used in web services). In XML-RPC, the input data are not URL parameters, but are stored in a XML content. As XML-RPC protocol wants it, an action defined for this type of request must obligatorily provide a response to XML-RPC format.  +
- +
-Knowing the type of request processed and the action, Jelix knows the type of the answer to be generated, and thus controls more or less the response generation. Thus, even the error case (an exception or other) occurring during the processing of the action, the exit format will always be the awaited one. A client who calls a web service with xmlrpc, will thus have no matter what happens, a response in the xmlrpc format. That brings a certain robustness to the application. +
- +
-===== Implementing an action ===== +
- +
-The actions are implemented in so-called controllers. Controllers are classes containing methods for each action. Controllers are placed in files : +
-controllers///controller_name//.//request_type//.php. +
- +
-In general, there is an index() method for the default action. +
- +
-Let's modifiy this default action. For this, open the contollers/default.classic.php. You should have this content: +
- +
-<code php> +
-class CTDefault extends jController { +
- +
-   function index () { +
-      $rep = $this->getResponse('html'); +
- +
-      return $rep; +
-   } +
-+
-</code> +
- +
-You see there are some naming conventions. Controller classes have a CT prefix, followed by the name of the controller (here: "default") indicated also in the action parameter, and the prefix of the file name *.classic.php.  +
- +
-There is an index() method, which retrieves the "html" type response. +
- +

en/tutorial/action-creation.1159173541.txt.gz · Last modified: 2006/10/17 20:31 (external edit)

Recent changes RSS feed Creative Commons License