Difference between revisions of "Xebra Documentation"

(Xeb)
Line 4: Line 4:
 
=Architecture Overview=
 
=Architecture Overview=
  
(img)
+
(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 HTTP Plugin (Apache Module or IIS7 Handler) forwards a request from the HTTP server to the Xebra Server and waits for a response.
Line 12: Line 12:
  
 
=Website Development=
 
=Website Development=
 +
 +
===Overview===
 +
A Xebra Webapplication consists of two parts: The Xeb-files and the controllers. Xeb-files consist of html code with embedded xeb-tags. They are translated to servlets. Controllers are Eiffel classes that connect the servlets to the rest of the eiffel classes. Features of controllers can be invoked from within a servlet. Typically, web designers create xeb files with a html editor. At the same time, web developers create controllers to provide business logic to the servlets. Then the web application is translated which means that the xeb-files are beeing generated to servlet eiffel classes and the whole webappliation is compiled to an executable file. The translation and compilation of the web application is done by the xebra server.
  
 
(img)
 
(img)
 +
===Step by step guide===
 +
# Setup an initial Eiffel project for your webapplication. For that matter you can use this [https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/framework/web/xebra/tools/scripts/create_website.sh script] which creates all neccesary files.
 +
# Create xeb files. Xeb files contain html code with embedded xeb-tags. See {here} for documentation about xeb files.
 +
# Create the eiffel classes.
 +
# Run the server and browse to http://localhost/yourwebapp. The server will translate and compile your webapp.
 +
  
The web designer creates xeb files with a html editor. Xeb files consist of html code with  The web
 
  
 
=Xebra Libraries=
 
=Xebra Libraries=

Revision as of 15:36, 29 June 2009


Architecture Overview

(img)

  1. 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.
  2. The Xebra Server forwards a request to the appropriate web application.


Website Development

Overview

A Xebra Webapplication consists of two parts: The Xeb-files and the controllers. Xeb-files consist of html code with embedded xeb-tags. They are translated to servlets. Controllers are Eiffel classes that connect the servlets to the rest of the eiffel classes. Features of controllers can be invoked from within a servlet. Typically, web designers create xeb files with a html editor. At the same time, web developers create controllers to provide business logic to the servlets. Then the web application is translated which means that the xeb-files are beeing generated to servlet eiffel classes and the whole webappliation is compiled to an executable file. The translation and compilation of the web application is done by the xebra server.

(img)

Step by step guide

  1. Setup an initial Eiffel project for your webapplication. For that matter you can use this script which creates all neccesary files.
  2. Create xeb files. Xeb files contain html code with embedded xeb-tags. See {here} for documentation about xeb files.
  3. Create the eiffel classes.
  4. Run the server and browse to http://localhost/yourwebapp. The server will translate and compile your webapp.


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. Additionally since it's not declaring any controller all controller calls are redirected to the ones in the template.

slave2.xeb

<page:include template="master"
<page:define_region id="form">
Other region 2
</page:define_region>
</page:include>

Templates can also be just imported partially. In slave2.xeb just the "form"-part of the template is implemented. This means that slave2.xeb is itself a template and will not be translated to a servlet.

slave3.xeb

<page:include template="slave2.xeb">
<page:define_region id="greetings">
</page:define_region>
</page:include>

This last example uses slave2.xeb as a template, which has one remaining region to implement: "greetings. The controller is still inherited from master.xeb, that is, controllers are transitive.

With these techniques we would be able to minimize duplicated code and hence errors in the xeb files, which are difficult to debug.

Xeb

Tag Description
<xeb:call feature="..." />

Calls the feature on the controller on render-time.

<xeb:loop times="..." >
...
</xeb:loop>

Loops its content "times" times.

<xeb:redirect url="..." />

Redirects the server to a new page at "url". The redirect is done server internally.

<xeb:iterate list="..." variable="..." type="...">
</xeb:iterate>

Includes a template

</page:fragment>

If used the page is not transformed to a servlet

Form