Differences ¶
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:tutorials:main:creating-action [2007/11/30 13:44] – laurent | en:tutorials:main:creating-action [2012/04/15 08:32] (current) – laurent | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Creating an action ====== | ||
- | |||
- | |||
- | |||
===== A little bit of theory ===== | ===== A little bit of theory ===== | ||
Line 21: | Line 17: | ||
- an HTTP request calls Jelix. Jelix creates an instance of a jRequest object which contains datas of the request. It then create an instance of your controller which corresponds to the asked action. | - an HTTP request calls Jelix. Jelix creates an instance of a jRequest object which contains datas of the request. It then create an instance of your controller which corresponds to the asked action. | ||
- A method | - A method | ||
- | - Then the method execute business processes, | + | - Then the method execute business processes, |
- The method of the controller create an instance of a jResponse object which is setup with datas or else (initialization of templates etc..). | - The method of the controller create an instance of a jResponse object which is setup with datas or else (initialization of templates etc..). | ||
- | - Jelix gets this jResponse object, launch the generation of the final document (html page, pdf..) and then send it to the browser. | + | - Jelix gets this jResponse object, launch the generation of the final document (html page, pdf..) and then send the result |
Line 34: | Line 30: | ||
In general, there is an //index()// method for the default action. | In general, there is an //index()// method for the default action. | ||
- | Let' | + | Let' |
<code php> | <code php> | ||
Line 68: | Line 64: | ||
</ | </ | ||
- | All the body of the page, i.e the content of the html tag < | + | All the body of the page, i.e the content of the html tag < |
Before beginning to code, let's see the content of the template. | Before beginning to code, let's see the content of the template. | ||
Line 101: | Line 97: | ||
</ | </ | ||
- | We added an instruction to specify to the response that we use the newslist.tpl template. | + | We added an instruction to specify to the response that we use the newslist.tpl template. |
- | A selector comprise a module name and a resource name separated by the " | + | A selector comprise a module name and a resource name separated by the " |
===== First display ===== | ===== First display ===== | ||
Line 109: | Line 105: | ||
We are now ready to display the first version of our action. For this, type the following url in your browser : | We are now ready to display the first version of our action. For this, type the following url in your browser : | ||
- | http:// | + | http:// |
You will then see the content of the template we created on the screen. | You will then see the content of the template we created on the screen. | ||
- | The action parameter is the name of the action to be executed. It is made from to parts, separated by an underscore | + | The action parameter is the name of the action to be executed. It is made from to parts, separated by a colon (in jelix 1.0b3.1 and prior, it was an underscore). The first part is the name of the controller, the second part is the name of the method to be executed. |
We can specify that this action will be the default action of the application. For this, open the configuration file news.org/ | We can specify that this action will be the default action of the application. For this, open the configuration file news.org/ | ||
Line 119: | Line 115: | ||
<code ini> | <code ini> | ||
startModule = " | startModule = " | ||
- | startAction = "default_index" | + | startAction = "default: |
</ | </ | ||
Line 126: | Line 122: | ||
http:// | http:// | ||
- | |||
- | ---- | ||
- | * Next : [[en: | ||
- | * Previous : [[en: | ||
- | * [[en: |