Properties for Struts HTML tags
This documentation describes the properties for the elements that are defined in the Struts HTML tag library. By default, the name of each of these elements has html: prefix.
Each Struts element has a number of properties that you can set by using the element's Properties view. Use this table of properties while working with the element's Properties view, to look up properties for which you want additional detail. Some properties have the same name but different usage in different elements. The properties are listed in alphabetical order.
Properties In element Description accept file Specifies a comma-delimited list of content types that the server to which you submit knows how to process. The list can be used by the client browser to limit the set of file options that is made available for selection. By default, no content type list is sent. accesskey button, cancel, checkbox, file, hidden, image, link, multibox, password, radio, reset, submit, text, textarea Specifies the keyboard character to be used to move focus immediately to this element. action form, frame, link Specifies the logical name of a global action that contains the actual content-relative URI of the destination of this transfer. You must specify one of the following attributes: action, forward, href, or page. You can modify this hyperlink dynamically by adding the paramId or name attribute. [Required for form] align image Specifies the alignment for this image. Deprecated: This attribute is deprecated in HTML 4. The suggested alternative is to use CSS. Fore more details, see www.w3.org/TR/REC-html40/struct/objects.html#h-13.7.4.
align img Specifies how the image is aligned, one of the following values:
- left
- Left-justifies, wrapping text on the right
- right
- Right-justifies, wrapping text on the left
- top
- Aligns the image with the top of the text on the same row
- middle
- Aligns the image's vertical center with the text base line
- bottom
- Aligns the image with the bottom of the text's base line
- texttop
- Aligns the image's top with that of the text font on the same line
- absmiddle
- Aligns the image's vertical center with the absolute center of the text
- absbottom
- Aligns the image with the absolute bottom of the text font on the same row
alt button, cancel, checkbox, file. hidden, image, img, multibox, password, radio, reset, select, submit, text, textarea Specifies alternate text for a component. This alternate text serves as content when the element cannot be rendered normally, for example, if the browser does not support forms or is set so that it does not display images. altKey button, cancel, checkbox, file, hidden, image, img, multibox, password, radio, reset, select, submit, text, textarea Specifies the message resources key of the alternate text for this element. anchor frame, link, include, rewrite Specifies an optional anchor tag to be added to the generated hyperlink. Do not specify a number sign (#) in the attribute value. border image, img Specifies the width (in pixels) of the border around this image. bundle errors, image, img, messages, option Specifies the servlet context attribute key for the MessageResources instance to use. It defaults to the application resources that is configured for the action servlet. cdata javascript If set to true and XHTML has been enabled, wraps the JavaScript code in a CDATA section to prevent XML parsing. The default is true to comply with the W3C's recommendation. collection options Specifies the name of the JSP bean (in some scope), which is a collection of other beans, each of which has properties named by the property and labelProperty attributes that are used to retrieve the value and label for each option. cols textarea Specifies the number of columns to display. disabled button, cancel, checkbox, file, image, option, multibox, password, radio, reset, select, submit, text, textarea If set to true, disables the input field. dynamicJavascript javascript If set to false, does not render dynamic JavaScript code. The default is true. enctype form Specifies the content encoding to be used to submit this form, if the method is POST. You must set this to multipart/form-data if you are using the file tag to enable file upload. If you omit this attribute, the browser default (normally application/x-www-form-urlencoded) is used. filter options, optionsCollection If set to false, suppresses filtering of option labels for sensitive characters in HTML. By default, such values are converted to their entity equivalents. focus form Specifies the field name (among the fields on this form) to which initial focus will be assigned with a JavaScript function. If you omit this attribute, no special JavaScript code for this purpose will be rendered. focusIndex form If the focus field is a field array, such as a radio button group, specifies the index in the array to receive focus. footer messages Specifies an optional message resource key that will be printed after the iteration of messages has finished. formName javascript Specifies the key (form name) to retrieve a specific set of validation rules. forward frame, include, rewrite Specifies the logical name of a global ActionForward that contains the actual content-relative URI of the destination of this transfer. You must specify one of the following attributes: action, forward, href, or page. You can modify this hyperlink dynamically by adding the paramId or name attribute. frameborder frame If set to 1, generates a frame border around this frame. The default is 0. frameName frame Specifies a value for the name attribute of the rendered frame element. header messages, Specifies an optional message resource key that will be printed before the iteration of the messages begins. height img Specifies the height of the image being displayed. Specifying this attribute along with along with width helps the browser render the page faster. href frame, link, include, rewrite Specifies the URL to which this hyperlink will transfer control if activated. You must specify one of the following attributes: action, forward, href, or page. You can modify this hyperlink dynamically by adding the paramId or name attribute. hspace img Specifies the amount of horizontal spacing between the image and the text. The text may be in the same paragraph or be wrapped around the image. htmlComment javascript Specifies whether or not to enclose the JavaScript code with HTML comments. This attribute is ignored in XHTML mode, because the script would be deleted by the XML parser. For details on hiding scripts from XML parsers, see the cdata attribute. The default is true. id messages Specifies the required name of a page scope JSP bean that will contain the current element of the collection of messages on each iteration, if it is not null. [Required] idName radio Specifies the name of the bean (in some scope) that will return the value of the radio tag. When the idName attribute, usually exposed by an iterator, is present, the value attribute is used as the name of the property on the idName bean that will return the value of the radio tag for this iteration. imageName img Specifies a name to be defined within this page so that you can reference it from scripts within the page. The value that you specify here will be the value of the name attribute in the generated img element. indexed button, checkbox, file, hidden, image, password, radio, select, submit, text, textarea Valid only inside an logic:iterate tag. If true, renders the name of the html tag as propertyName[int], where int will be generated for every iteration and taken from the ancestor logic:iterate tag. indexed link Valid only inside an logic:iterate tag. If true, adds the indexed parameter with name from indexId attribute to the query string. The indexed parameter looks like index[int], where int will be generated for every iteration and taken from the ancestor logic:iterate tag. indexId link Specifies a different name for the indexed parameter. For more information, see the indexed attribute. ismap img Specifies the name of the server-side map to which this image belongs. key option If specified, defines the message key to be looked up in the resource bundle specified by bundle for the text displayed to the user for this option. The default is to take from the body content of this tag the text to be displayed. label optionsCollection Specifies the property of the bean within the collection which represents the label to be rendered for each option. The default is label. labelName options Specifies the name of the JSP bean (in some scope) that contains the collection of labels to be displayed to the user for these options. labelProperty options Specifies the property of the form bean, or the bean specified by the labelName attribute, that will return the collection of labels to be displayed to the user for these options. linkName link Specifies the anchor name to be defined within this page so that hyperlinks within the page can reference it. The value that you specify here will be the value of the name attribute in the generated anchor tag. locale errors, image, img, messages, option Specifies the value of the request or session locale attribute to be used to look up internationalized messages. locale html If set to true stores a locale in the session based on the current request's Accept-Language header (if any) if none has currently been set. This attribute creates a session if one does not already exist. The lang attribute is assigned the appropriate language code. Deprecated: Creating a session is undesirable for applications that do not support them. Use the lang attribute to achieve the same result without creating a session.
longdesc frame Specifies the URI of a long description of the frame. This description supplements the short description provided by the title attribute and may be particularly useful for nonvisual user agents. lowsrc img Specifies an image for users who have low-resolution graphics cards. Deprecated: This attribute is not defined in the HTML 4.01 specification and will be removed in a future version of Struts.
marginheight frame Specifies the amount of space (in pixels) to be left between the frame's contents and its top and bottom margins. marginwidth frame Specifies the amount of space (in pixels) to be left between the frame's contents and its left and right margins. maxlength file, password, text Specifies the maximum number of input characters to accept. message messages If set to true, retrieves the bean from the Globals.MESSAGE_KEY constant string and ignores any value assigned to the name attribute. By default the tag retrieves from the Globals.ERROR_KEY constant string the bean over which it will iterate. method form, javascript Specifies the HTTP method (GET or POST) that will be used to submit this request. multiple select Specifies the maximum number of input characters to accept. name checkbox, errors, file, form, frame, hidden, img, link, messages, multibox, options, password, radio, rewrite, select, text, textarea, include Specifies the name of a JSP bean that contains a map that represents the query parameters (if property is not specified) or a JSP bean whose property getter is called to return a map (if property is specified). name optionsCollection Specifies the attribute name of the bean whose properties are consulted when rendering the current value of this input field. By default, the bean associated with the form tag within which this element is nested is utilized. noresize frame If set to true, prevents users from resizing the frame. The default is false. onblur button, cancel, checkbox, file, hidden, image, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element loses input focus. onchange button, cancel, checkbox, file, hidden, image, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element loses input focus and its value has changed. onclick button, cancel, checkbox, file, hidden, image, img, link, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element receives a mouse click. ondblclick button, cancel, checkbox, file, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element receives a mouse double-click. onfocus button, cancel, checkbox, file, hidden, image, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element receives input focus. onkeydown button, cancel, checkbox, file, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element has focus and a key is depressed. onkeypress button, cancel, checkbox, file, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element has focus and a key is depressed and released. onkeyup button, cancel, checkbox, file, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element has focus and a key is released. onmousedown button, cancel, checkbox, file, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element is under the mouse pointer and a mouse button is depressed. onmousemove button, cancel, checkbox, file, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element is under the mouse pointer and the pointer is moved. onmouseout button, cancel, checkbox, file, hidden, image, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element was under the mouse pointer but the pointer was moved outside the element. onmouseover button, cancel, checkbox, file, hidden, image, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element was not under the mouse pointer but the pointer is moved inside the element. onmouseup button, cancel, checkbox, file, hidden, image, link, multibox, password, radio, reset, select, submit, text, textarea Runs the JavaScript event handler when this element is under the mouse pointer and a mouse button is released. onreset form Runs the JavaScript event handler if the form is reset. onsubmit form Runs the JavaScript event handler if the form is submitted. page frame, image, img, javascript, link, include, rewrite Specifies the module-relative path, beginning with a slash (/), to which this hyperlink, if activated, will transfer control. You must specify one of the following attributes: action, forward, href, or page. You can modify this hyperlink dynamically by adding the paramId or name attribute. pageKey image, img Specifies the key of the message resources string that specifies the module-relative path of the image for this input tag. paramId frame, img, link, rewrite Specifies the name of the request parameter that will be added dynamically to the generated hyperlink. The corresponding value is defined by the paramName and (optional) paramProperty attributes and is optionally scoped by the paramScope attribute. paramName frame, img, link, rewrite Specifies the name of a JSP bean that is a String containing the value for the request parameter named by paramId (if you omit paramProperty), or a JSP bean whose property getter is called to return a String (if you specify paramProperty). The JSP bean is constrained to the bean scope specified by the paramScope property, if it is specified. paramProperty frame, img, link, rewrite Specifies the name of a property of the bean specified by the paramName attribute, whose return value must be a String containing the value of the request parameter (named by the paramId attribute) that will be added dynamically to this hyperlink. paramScope frame, img, link, rewrite Specifies the scope within which to search for the bean specified by the paramName attribute. By default, all scopes are searched. property button, checkbox, file, multibox, password, select Specifies the name of the request parameter that will be included with this submission, set to the specified value. [Required] property cancel Specifies the name of the request parameter that will be included with this submission, set to the specified value. Attention: If you set this attribute to a value other than the default, this will not be recognized as the Cancel key by the Struts controller servlet or the Action.isCancelled() method. You will need to do your own cancellation detection.property errors Specifies the name of the property for which error messages should be displayed. By default, all error messages (regardless of property) are displayed. property frame, img, link, rewrite Specifies the name of a property of the bean specified by the name attribute, whose return value must be a java.util.Map class that contains the query parameters to be added to the hyperlink. If you specify this attribute, also specify the name attribute. property hidden Specifies the name of this input field and the name of the corresponding bean property if value is not specified. The corresponding bean property (if any) must be of type String. [Required] property image Specifies the property name of this image tag. The parameter names for the request will appear as property.x and property.y, the x and y representing the coordinates of the mouse click for the image. A way of retrieving these values through a form bean is to define getX(), getY(), setX(), and setY() methods, and specify your property as a blank string (property=""). property messages Specifies the name of the property for which messages should be displayed. By default, all messages (regardless of property) are displayed. property options Specifies the property of the form bean, or the bean specified by the name attribute, that will return the collection of valuesreturned to the server for these options. property radio Specifies the corresponding bean property for this radio tag. [Required] property reset Specifies the name of the input field that will be generated. property text, textarea Specifies the name of this input field, and the name of the corresponding bean property if value is not specified. The corresponding bean property (if any) must be of type String. [Required] readonly password, text, textarea If set to true, makes this input field read-only. redisplay password If set to false, indicates that existing values will not be redisplayed. Even though a redisplayed value is shown as asterisks on the visible HTML page, the clear text of the actual password value is visible though the Show Page Source menu option of the client browser. The default is true. You may wish to set the value to false on login pages. rows textarea Specifies the number of rows to display. scope frame, img, link, rewrite Specifies the scope within which to search for the bean specified by the name attribute. By default, all scopes are searched. scrolling frame Specifies whether scroll bars are to be created unconditionally (yes), never (no), or only when needed (auto). server base Specifies the server name to use instead of request.getServerName(). size file, password, select, text Specifies the number of character positions to allocate. src frame, image, img, javascript Specifies the source URL of the image for this input tag. srcKey image, img Specifies the key of the message resources string that specifies the source URL of the image for this input tag. staticJavascript javascript Specifies whether or not to render the static JavaScript code. The default is true. style button, cancel, checkbox, file, form, frame, hidden, image, img, link, multibox, option, options, optionsCollection, password, radio, reset, select, submit, text, textarea Specifies CSS style information for the component (for example, style="font-size : 8pt ; color : red"). styleClass button, cancel, checkbox, file, form, frame, hidden, image, img, link, multibox, option, options, optionsCollection, password, radio, reset, select, submit, text, textarea Specifies the CSS stylesheet class to be applied to this HTML element. This creates a class attribute. styleId button, cancel, checkbox, file, form, frame, hidden, image, img, link, multibox, option, password, radio, reset, select, submit, text, textarea Specifies an identifier to be assigned to this HTML element. This creates an id attribute. tabindex button, cancel, checkbox, file, image, link, multibox, password, radio, reset, select, submit, text, textarea Sets the tab order (ascending positive integers) for this element. target base, form, link Specifies a Window target to which this form is submitted, such as for use in framed presentations. title button, cancel, checkbox, file, frame, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Specifies the advisory title for this element. titleKey button, cancel, checkbox, file, frame, hidden, image, img, link, multibox, password, radio, reset, select, submit, text, textarea Specifies the message resources key for the advisory title for this element. transaction frame, link, include, rewrite If set to true, includes in the generated hyperlink any current transaction control token, so that it will pass an isTokenValid() test in the receiving action. type form Specifies the name of a form-bean class that indicates the type of form that is being created. usemap img Specifies the name of the map as defined within this page for mapping hot-spot areas of this image. value button, cancel, image, password, radio, reset, submit Specifies the value of the label to be placed on this button. This value will also be submitted as the value of the specified request parameter. value checkbox, multibox Specifies the value to be transmitted if this check box is checked when the form is submitted. By default, the value on is returned if the check box is checked. value file, hidden, text, textarea Specifies the value to which this field should be initialized. value option Specifies the value to be submitted for this field if this option is selected by the user. [Required] value optionsCollection Specifies the property of the bean within the collection which represents the value to be rendered for each option. The default is value. value select Specifies the value to compare with for marking an option selected. vspace img Specifies the amount of vertical spacing between the image and the text, above and below. width img Specifies the width of the image being displayed. Specifying this attribute along with along with height helps the browser render the page faster. write hidden If set to true, renders the value of this field to the response page to make it visible, in addition to creating an HTML type="hidden" element? By default, only the hidden element is created. xhtml html If set to true, renders xml:lang and xmlns attributes on the generated html element. This also causes all other html tags to render as XHTML 1.0. (The <html:xhtml/> tag has a similar purpose.)
Related tasks
Adding Struts tags to a JSP file
Related reference
Feedback
Properties for Struts bean tags
Properties for Struts tiles tags
Properties for Struts logic tags
Properties for Struts nested tags
Properties for Struts tags