Xebra Documentation

Revision as of 07:46, 1 July 2009 by Sandrod (Talk | contribs) (Xebra Tag Libraries)


Xebra HTTP Server Plugins

Xebra Tag Libraries

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>

Iterates over a list (defined with "list" as a controller call). The current item is stored in "variable" which is of type "type". This variable is then available for its children.

<xeb:container>
...
</xeb:container>

This simple tag just groups parts of the site. Can be used to conditionally render some parts with the "render" attribute.

<xeb:display feature="..." />

The display tag simply displays what is written in feature.

Form

Tag Description
<f:form class="..." variable="...">
</f:form>

All form tags have to be contained in a f-form. A variable and class can be optionally defined to automatically wrap input forms to an object.

<f:button value="..." action="..."/>

A button is a normal html button. It is associated with a controller function ("action") which is executed if the validation of all inputs field where successful. The automatically wrapped object is then passed to the action. The value designates the Label on the button.

<f:input_text value="..." name="..." text="..."/>
<f:input_secret value="..." name="..." text="..." />

These two input fields are basically the same. The designated normal html inputs. Additionally they provide a name which makes them identifiable for validation output. f-validator tags can be added to the inputs to define validators.

<f:textarea value="..." name="..." text="..." rows="..." cols="..."/>

Basically the same as the input fields but with some additional auxiliary textarea-specific attributes (rows, cols).

<f:command_link label="..." action="..." variable="..." />

A command link is a html link. It acts though like a button and executes the defined action on the controller. If a variable is defined, it will be passed to the action (feature). Variable names can be used from f-form or xeb-iterate.

<f:validator class="..." />

A validator validates an input. It can be added to input fields (or textareas) to check the input.

<f:validation_result name="..." />

Outputs potential validation errors coming from the input field with the name "name".

Example

For the forms framework we will use a simple display of reservations with an input mask and delete command links.

<table>
	<tr>
		<td>Name</td>
		<td>Date</td>
		<td>Persons</td>
		<xeb:container render="authenticated_admin">
			<td>Delete</td>
		</xeb:container>
		<xeb:container render="not_authenticated_admin">
			<td>Details</td>
		</xeb:container>
	</tr>
	<f:form>
	<xeb:iterate list="global_state.db.reservations" variable="reservation" type="RESERVATION">
		<tr>
			<td><xeb:display feature="#{reservation.name}"/></td>
			<td><xeb:display feature="#{reservation.date}"/></td>
			<td>
			<f:command_link label="Delete" action="delete" variable="reservation" />
			</td>					
		</tr>
	</xeb:iterate>
	</f:form>
</table>
<h2>New Reservation</h2>
<f:form variable="new_reservation" class="RESERVATION">
<table>
	<tr>
		<td>Name</td>
		<td><f:input_text value="name" name="a_name" text="#{new_reservation.name}" /></td>
	</tr>
	<tr>
		<td>Date</td>
		<td><f:input_text value="date" name="a_date" text="#{new_reservation.date}" /></td>
	</tr>
	<tr>
		<td colspan="2">
		<div align="center">
		<f:button value="Save" action="save" type="submit" /></div>
		</td>
	</tr>
</table>
</f:form>

Tag Attributes

While most tag attributes are plain text and thus static, sometimes it is useful or even necessary to use dynamically bound attributes. In Xebra there are two different types of dynamic attributes:

Tag Description
... attr="%=call%"...

Call designates a controller feature which returns a STRING.

... attr="#{variable.name}"...

Uses a - predefined (form/iterate) - variable to retrieve a value.