Difference between revisions of "Xebra Write Xeb File"
(→Wrapped forms) |
|||
Line 46: | Line 46: | ||
To validate the input field we simply added two validators to the desired input field. Now if the validators report an invalid input the save action is not executed and errors messages are stored into a list. They can be displayed with a validation_result tag, by using the same identifier as the input_text ("a_name") | To validate the input field we simply added two validators to the desired input field. Now if the validators report an invalid input the save action is not executed and errors messages are stored into a list. They can be displayed with a validation_result tag, by using the same identifier as the input_text ("a_name") | ||
+ | |||
+ | =Command links= |
Revision as of 09:20, 6 July 2009
Hello World
The simlest xeb file is a hello world example:
Hello World!
This page will just display "Hello World!" as is.
Iteration over lists and display
If we have a list and want to iterate over it, we can simply use the iterate tag.
<xeb:iterate list="persons" variable="person" class="PERSON"> <xeb:display feature="#{person.name}" /> </xeb>
Notice the that the feature attribute is special. Attributes with "#{}" denote variable attributes and use defined variables (here the person from iterate).
Wrapped forms
HTML forms have their managed counterpart in XEBRA. If we want to retrieve all the data from a form automatically, we can use the Form tag library ("f").
<f:form variable="new_person" class="PERSON"> <f:input_text value="name" name="a_name" text="#{new_person.name}" /> <f:button value="Save" action="save"/> </f:form>
This will generate a page with a form, a text field and a button. On a click on the button a new object of type PERSON is created and the name is set to the value in the text field. Most of the time we want to validate inputs from forms. With validators we can check if an input is valid.
<f:form variable="new_person" class="PERSON"> <f:input_text value="name" name="a_name" text="#{new_person.name}" > <f:validator class="NOT_EMPTY_VALIDATOR" /> <f:validator class="PERSON_NAME_VALIDATOR" /> </f:input> <f:validation_result name="a_name" /> <f:button value="Save" action="save"/> </f:form>
To validate the input field we simply added two validators to the desired input field. Now if the validators report an invalid input the save action is not executed and errors messages are stored into a list. They can be displayed with a validation_result tag, by using the same identifier as the input_text ("a_name")