tags: field - text - number - password - textarea - checkbox - file - date - detail - suggest - fieldArea
Those tags shared a lot of code with the tags in the struts-html taglib, and support nearly all the attributes the tags in the struts-html taglib support. The main differences are:
The field display mode can be set by using FormUtils.setFieldDisplayMode(request, form, fieldName, mode)
HTML code put inside the field tag will be render after the input tag. This makes is possible, for example, to add a button allowing to select a value for the input field in a popup page.
| Attribute Name | Description |
|---|---|
| key | The label key of the requested label. If the key does not have a corresponding value in the message resources, the key is displayed. [EL] |
| arg0, arg1, arg2, arg3, arg4 | Optional parametric replacement values. [EL] |
| name | Name of the bean in the pageContext, request, session or application scope we want to edit a property. Default is the struts form bean |
| property | Property of the bean to view/edit [EL] |
| isRequired | If set to true a red star is displayed after the field if its value is null. Value: true | false Default: false [EL] |
| styleClass | css style class to use |
| errorStyleClass | css style class to use for field with error |
| help | Display an help text. |
| helpStyleClass | css style class to use for field with help |
| mode | Field display mode. The mode must match the pattern <create field mode>,<edit field mode>,<inspect field mode>. The possible values for a field mode are E (editable), I (inspectable+hidden, ie read-only), N (not displayed), H (hidden), P (inspect if present), S (show, inspect but no hidden field), R (readonly), D (disabled) [EL] |
| model | Renderer model to use to display the field. See the skin page for more information |
| policy | Name of the display policy to user |
| hint | Key of a hint message to display as a tooltip on the label |
| tooltip | Key of a message to display as a tooltip on the field [EL] |
| layout | If set to false, do not generate layout code (ie only generate the <input> tag). This make it possible to use only the "display mode" framework of struts-layout. |
| layoutId | DHTML id of the tag. This allows to show/hide the tag with the following code: document.getElementById(layoutId + "F").style = "none" to hide (or "" to show); document.getElementById(layoutId + "L").style = "none" to hide (or "" to show); layoutId + "F" is the input field cell, layoutId + "L" is the label cell. |
| onchange | onchange javascript handler [EL] |
| onHelpMouseOver | onMouseOver help area javascript handler |
| onHelpMouseOut | onMouseOut help area javascript handler |
| onHelperClick | onClick helper javascript handler. If it's specified, an helper for the field is displayed after the field |
| value | field initial value (default value is the corresponding Struts ActionForm property) [EL] |
Render a text input field.
| Attribute Name | Description |
|---|---|
| type | In inspect mode, format the value using the specified struts-layout formatter [EL] |
| editType | In edit mode, format the value using the specified struts-layout formatter [EL] |
Render a password input field
| Attribute Name | Description |
|---|---|
| redisplay | If set to true redisplay the password. Note that the password is readable in the generated HTML code |
Render a file upload/download field
| Attribute Name | Description |
|---|---|
| fileKey | Key of the text to display a file name |
| fileName | Property of the form bean giving the name of the file to download. If not set, fileKey is used. |
| filePath | Property of the form bean giving the url to use to download the file |
Render a date input field
This tag is a text input field modified to display a popup date picker calendar
Attributes
| Attribute Name | Description |
|---|---|
| calendarTooltip | Alternative text key for the calendar link. Default text is "pick up a date". |
| startYear | If set, year the calendar starts. |
| endYear | If set, year the calendar ends. |
| patternKey | If set, key of the date pattern to use |
Render a detail
This tag is used to display the details of a row. The tag works as a <layout:text> tag, expect that it takes its data from its master collection instead of the Struts form bean.
The value of the property attribute must be the value of the property attribute of one of the <layout:collectionDetail> tag
Check the FAQ for an example.
Render an text field with a suggestions list: when a user types a character, the tag shows suggestions matching typed word, and the user just have to use keyboard or mouse in order to choose one of these suggestions.
In fact, when a user types a character, a Struts action is called. This action class has two particularities:
Attributes
| Attribute Name | Description |
|---|---|
| all | Include all form fields for the computation of the siggestions list. If set to true, the action must extends MultipleSuggestAction. Default : false |
| suggestAction | Path of the action to call in order to get the suggestions list |
| suggestCount | Max number of suggestions to return (default: 10) |
| suggestEncoding | Character encoding to use for suggestions to return (default: ISO-8859-1) |
| minWordLength | Minimal number of characters to type in order to get suggestions (default: 1) |
| timeout | Time to wait in order to get suggestions each time a character is typed, in milliseconds (default: 0) |
Render a custom field
The fieldArea tag does not render any specific field : its content must be defined using nested HTML, Struts or Struts-Layout tags. the fieldArea tag ensures the field label and value parts are aligned with other Struts-Layout field tags.
Example:
<layout:form action="/someAction"> <layout:text key="field.key" property="someProperty"/> <layout:fieldArea key="otherField.key"> <table>...</table> </layout:fieldArea> </layout:form>
Render a field
This is a deprecated tag that could display a text, password, textarea or checkbox input field.
Attributes
| Attribute Name | Description |
|---|---|
| arg0, arg1, arg2, arg3, arg4, key, locale, name, property, styleClass, cols, maxlength, rows, size | as in <html:text> and <bean:message> |
| access | Specify if the field is read-write or read-only. Value: READWRITE | READONLY Default: READWRITE |
| isRequired | If set to TRUE display a star after the field. Value: TRUE | FALSE Default: FALSE |
| type | Value: PASSWORD | TEXT | TEXTAREA | NUMBER | BOOLEAN | DATE. Default: TEXT |