Difference between revisions of "Xebra Documentation"
(→Example) |
(→Example) |
||
Line 68: | Line 68: | ||
This example shows the workings of the template framework. It consists of a master page which acts as a template and three different types of usage of this template. | This example shows the workings of the template framework. It consists of a master page which acts as a template and three different types of usage of this template. | ||
− | master.xeb | + | '''master.xeb''' |
<xml> | <xml> | ||
<html> | <html> | ||
Line 83: | Line 83: | ||
The master page is "deferred", since there are page:declare_region tags. The translator detects the undefined regions and doesn't generate a servlet from this xeb file. | The master page is "deferred", since there are page:declare_region tags. The translator detects the undefined regions and doesn't generate a servlet from this xeb file. | ||
− | slave1.xeb | + | '''slave1.xeb''' |
<xml> | <xml> | ||
<page:include template="master"> | <page:include template="master"> | ||
Line 95: | Line 95: | ||
</xml> | </xml> | ||
− | + | slave1.xeb uses master.xeb as a template and includes it via the page-include tag. Since master.xeb declares two regions, slave1 defines them. The content of the define-region tags are inserted at the locations of the respective declare-region tags of the template. From this xeb file a servlet is generated. | |
+ | '''slave2.xeb''' | ||
<xml> | <xml> | ||
<html> | <html> |
Revision as of 15:23, 29 June 2009
Contents
Architecture Overview
(img)
- The Xebra HTTP Plugin (Apache Module or IIS7 Handler) forwards a request from the HTTP server to the Xebra Server and waits for a response.
- The Xebra Server forwards a request to the appropriate web application.
Website Development
(img)
The web designer creates xeb files with a html editor. Xeb files consist of html code with The web
Xebra Libraries
Page
The page libraries consists of the core tags needed for page configuration and composition. The Tags are:
Tag | Description |
---|---|
<page:controller class="..." />
|
Defines the controller which should be used for the xeb page |
<page:declare_region id="..." />
|
Declares a region at the specific point in the xeb page |
<page:define_region id="..."> ... </page:define_region> |
Defines a region from a template, can only be used inside a page-include tag |
<page:include id="..." />
|
Includes a template |
</page:fragment>
|
If used the page is not transformed to a servlet |
Example
This example shows the workings of the template framework. It consists of a master page which acts as a template and three different types of usage of this template.
master.xeb
<html> <page:controller class="DEFAULT_CONTROLLER"/> <body> <h1> <page:declare_region id="greeting" /> </h1> <page:declare_region id="form" /> </body> </html>
The master page is "deferred", since there are page:declare_region tags. The translator detects the undefined regions and doesn't generate a servlet from this xeb file.
slave1.xeb
<page:include template="master"> <page:define_region id="greeting"> Hello, I'm Slave 1 </page:define_region> <page:define_region id="form"> Other region </page:define_region> </page:include>
slave1.xeb uses master.xeb as a template and includes it via the page-include tag. Since master.xeb declares two regions, slave1 defines them. The content of the define-region tags are inserted at the locations of the respective declare-region tags of the template. From this xeb file a servlet is generated.
slave2.xeb
<html> <page:controller class="SLAVE2_CONTROLLER" /> <page:include template="master" <page:define_region id="form"> Other region 2 </page:define_region> </page:include> </html>
slave3.xeb
<page:include template="slave2.xeb"> <page:controller class="SLAVE2_CONTROLLER" /> <page:define_region id="greetings"> </page:define_region> </page:include>
With these techniques we would be able to minimize duplicated code and hence errors in the xeb files, which are difficult to debug.
This code will generate exactly three servlets, SLAVE1_SERVLET.e , SLAVE2_SERVLET.e and SLAVE3_SERVLET.e. master.xeb and form.xeb are fragments. SLAVE1_SERVLET inherits the controller from the master page, while SLAVE2_SERVLET "overwrites" this definition and uses SLAVE2_CONTROLLER. All the pages which are deferred (like master.xeb) are not compiled to servlets. Neither are pages which are denoted with the tag page:fragment. Template pages could be used to differentiate views based on roles. For instance one could think of roles like 'guest', 'user' and 'admin'. 'guest' and 'user' would then have pages which inherit from a 'master_page', implementing their own menus. 'admin' in contrast would inherit from 'user', since it is a user with additional rights. So it would have to extend the menu and contents. Sub pages which have been added through page:include could act as master pages as well, further encouraging code reuse.