Input field tags

tags: field - text - number - password - textarea - checkbox - file - date - detail - suggest - fieldArea

Common behaviour of the text, password, textarea, checkbox, file date and detail tags

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 layout tags render a label.
  • The tags can be set to non editable.
  • The tags display the errors which are associated with their properties.
  • The tags can be set to required, and in this case will display a star to indicate it.

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.

Basic attributes

Attribute NameDescription
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]
nameName of the bean in the pageContext, request, session or application scope we want to edit a property. Default is the struts form bean
propertyProperty of the bean to view/edit [EL]
isRequiredIf set to true a red star is displayed after the field if its value is null. Value: true | false Default: false [EL]
styleClasscss style class to use
errorStyleClasscss style class to use for field with error
helpDisplay an help text.
helpStyleClasscss style class to use for field with help
modeField 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]
modelRenderer model to use to display the field. See the skin page for more information
policyName of the display policy to user
hintKey of a hint message to display as a tooltip on the label
tooltipKey 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.
layoutIdDHTML 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.
onchangeonchange javascript handler [EL]
onHelpMouseOveronMouseOver help area javascript handler
onHelpMouseOutonMouseOut help area javascript handler
onHelperClickonClick helper javascript handler. If it's specified, an helper for the field is displayed after the field
valuefield initial value (default value is the corresponding Struts ActionForm property) [EL]

text

Render a text input field.

Attribute NameDescription
typeIn inspect mode, format the value using the specified struts-layout formatter [EL]
editTypeIn edit mode, format the value using the specified struts-layout formatter [EL]

number

A text input field that allow allows digits.

password

Render a password input field

Attribute NameDescription
redisplayIf set to true redisplay the password. Note that the password is readable in the generated HTML code

textarea

Render a textarea input field.

No specific parameters

checkbox

Render a checkbox

No specific parameters

file

Render a file upload/download field

Attribute NameDescription
fileKeyKey of the text to display a file name
fileNameProperty of the form bean giving the name of the file to download. If not set, fileKey is used.
filePathProperty of the form bean giving the url to use to download the file

date

Render a date input field

This tag is a text input field modified to display a popup date picker calendar

Attributes

Attribute NameDescription
calendarTooltipAlternative text key for the calendar link. Default text is "pick up a date".
startYearIf set, year the calendar starts.
endYearIf set, year the calendar ends.
patternKeyIf set, key of the date pattern to use

detail

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.

suggest

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:

  • It must extends the fr.improve.struts.taglib.layout.suggest.SuggestAction class.
  • It must implement an inherited abstract method named getSuggestionList(HttpServletRequest in_request, String in_word): this method returns a suggestions list (as a String Collection) from the typed word (as in_word).

Attributes

Attribute NameDescription
allInclude all form fields for the computation of the siggestions list. If set to true, the action must extends MultipleSuggestAction. Default : false
suggestActionPath of the action to call in order to get the suggestions list
suggestCountMax number of suggestions to return (default: 10)
suggestEncodingCharacter encoding to use for suggestions to return (default: ISO-8859-1)
minWordLengthMinimal number of characters to type in order to get suggestions (default: 1)
timeoutTime to wait in order to get suggestions each time a character is typed, in milliseconds (default: 0)

fieldArea

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>		

field

Render a field

This is a deprecated tag that could display a text, password, textarea or checkbox input field.

Attributes

Attribute NameDescription
arg0, arg1, arg2, arg3, arg4, key, locale, name, property, styleClass, cols, maxlength, rows, size as in <html:text> and <bean:message>
accessSpecify if the field is read-write or read-only. Value: READWRITE | READONLY Default: READWRITE
isRequiredIf set to TRUE display a star after the field. Value: TRUE | FALSE Default: FALSE
typeValue: PASSWORD | TEXT | TEXTAREA | NUMBER | BOOLEAN | DATE. Default: TEXT