Difference between revisions of "Xebra Taglib Form"

(Form)
(Form)
 
(6 intermediate revisions by the same user not shown)
Line 20: Line 20:
 
|
 
|
 
<xml>
 
<xml>
<f:button value="..." action="..."/>
+
<f:button text="..." action="..."/>
 
</xml>
 
</xml>
 
|
 
|
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.
+
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 text designates the Label on the button.
 
|-
 
|-
 
|
 
|
 
<xml>
 
<xml>
<f:input_text value="..." name="..." text="..." type="..."/>
+
<f:input_text value="..." name="..." text="..." type="..." label="..."/>
 
</xml>
 
</xml>
 
|
 
|
 
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 as in all wrappable inputs. The type argument is optional and defines the type of the input (for instance 'secret').
 
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 as in all wrappable inputs. The type argument is optional and defines the type of the input (for instance 'secret').
 +
The optional 'label' attribute adds a label to the input.
 
|-
 
|-
 
|
 
|
 
<xml>
 
<xml>
<f:textarea value="..." name="..." text="..." rows="..." cols="..."/>
+
<f:text_area value="..." name="..." text="..." rows="..." cols="..."/>
 
</xml>
 
</xml>
 
|
 
|
Line 41: Line 42:
 
|
 
|
 
<xml>
 
<xml>
<f:drop_down_list items="..." type="..."/>
+
<f:drop_down_list items="..." name="..." value="..." [label="..."] [selected_index="..."]/>
 
</xml>
 
</xml>
 
|
 
|
This tag generates the equivalent to a <xml><select><option>...</option>...</select></xml> statement. items designates the list to be used in the drop down and type is an optional parameter. It defines the type of the items. If not set, it assumes Strings.
+
This tag generates the equivalent to a <xml><select><option>...</option>...</select></xml> statement. items designates the list to be used in the drop down and type is an optional parameter. It defines the type of the items. If not set, it assumes Strings. Selected_index defines the item that should be selected. The value provided has to match with the "is_equal" feature of the object.
 
|-
 
|-
 
|
 
|
 
<xml>
 
<xml>
<f:check_box name="..." value="..."/>
+
<f:check_box name="..." label=".." value="..."/>
 
</xml>
 
</xml>
 
|
 
|
Line 55: Line 56:
 
|
 
|
 
<xml>
 
<xml>
<f:command_link label="..." action="..." variable="..." />
+
<f:command_link text="..." action="..." variable="..." />
 
</xml>
 
</xml>
 
|
 
|

Latest revision as of 05:49, 30 November 2009

About | Installation | Documentation | Tutorials | Frequently Asked Questions


The Form Tag Library captures all the functionality related to html forms. This includes automatic wrapping of input to objects and validation.

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. This variable is known in the scope of the form. Note that forms cannot be nested, as in normal xhtml forms.

<f:button text="..." 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 text designates the Label on the button.

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

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 as in all wrappable inputs. The type argument is optional and defines the type of the input (for instance 'secret'). The optional 'label' attribute adds a label to the input.

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

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

<f:drop_down_list items="..." name="..." value="..." [label="..."] [selected_index="..."]/>

This tag generates the equivalent to a <select><option>...</option>...</select> statement. items designates the list to be used in the drop down and type is an optional parameter. It defines the type of the items. If not set, it assumes Strings. Selected_index defines the item that should be selected. The value provided has to match with the "is_equal" feature of the object.

<f:check_box name="..." label=".." value="..."/>

A normal checkbox which is automatically wrapped to a boolean.

<f:command_link text="..." 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="..." variable="...">
...
</f:validation_result>

Stores a variable with the name of the variable attribute. It contains the error message. If there is more than one error it iterates over all errors. In this way formatting of errors is (almost) free to the designer.

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>