Forms
The <form> tag include a target action and event that are not only used to generate the target URL but also dictates the validations that will be applied to the input fields.
Form input fields
Each form input field will generate automatically some details such as the maxlength and size attributes, and the corresponding decorator will generate the input field label.
Form input fields have a name that is used as a property path inside the action class. The input field will get bound to the associated java property, such as:
Automatic CSS classes
Some validators and converters contribute to the calculated CSS class of any field.
- number: added if the property is a number.
- error: added if the field has associated validation/conversion errors.
- date: added if the property is a date.
- required: added if the property is required.
- string: added if the property is a string.
- unauthorized: A link that points to an event that the user has insufficient privileges to invoke.
These styles can be used to adjust styles using CSS or to connect with javascript handlers.
Displaying form errors
Form errors can be displayed using a <l:errors> tag. When nested inside a form, this tag will display a list of errors that have not been already rendered bound to a field.
The same HTML structure will be used by javascript validation code, so an error can be generated by the server and cleaned up by the browser when the user fixes the wrong data, before sending again to the server.
Enabling javascript validation
To validate form input using javascript: