Struts-Faces Integration Tag Library

This tag library provides custom action functionality that is similar to that provided by the Struts 1.1 tag libraries, but is built on top of the JavaServer Faces rendering architecture.

This tag library includes the following tags:

Tag NameDescription
base Render an HTML <base> element
body Render nested JSP body content as a Faces component
errors Conditionally display a set of accumulated error messages
form Render a form suitable for submission to a Struts Action
html Render an HTML <html> element
javascript Render JavaScript validation based on the validation rules loaded by the ValidatorPlugIn.
message Render a localized message looked up from a message resources bundle
stylesheet Render an HTML <link> relative reference to a stylesheet
write Render the value of the specified model object or text string
base - Render an HTML <base> element

Renders an HTML <base> element with an href attribute pointing to the absolute location of the enclosing JSP page. This tag is valid only when nested inside an HTML <head> element. This tag is useful because it allows you to use relative URL references that are based on the URL of the page itself, rather than the URL to which the most recent submit took place.

Attribute NameDescription
id Component id of this component.
rendered Boolean attribute indicating whether this component should be rendered or not.
target Target frame for this base reference.
body - Render nested JSP body content as a Faces component

Encapsulates the output of JSP content nested in this tag as a JavaServer Faces UIOutput component rendered with the Text renderer type.

Attribute NameDescription
id Component id of this component.
rendered Boolean attribute indicating whether this component should be rendered or not.
errors - Conditionally display a set of accumulated error messages

Displays a list of error messages prepared by form bean or business logic validation processing.

In order to use this component successfully, you must have defined an application scope MessageResources bean under the specified attribute name, with optinal definitions for the following message keys:

  • errors.header - Text that will be rendered before the error messages list.
  • errors.footer - Text that will be rendered after the error messages list.
  • errors.prefix - Text that will be rendered before each individual error in the list.
  • errors.suffix - Text that will be rendered after each individual error in the list.
Attribute NameDescription
bundle

Name of the servlet context attribute under which the desired MessageResources bundle is stored. If not specified, the default bundle for this sub-application will be used.

id Component id of this component.
rendered Boolean attribute indicating whether this component should be rendered or not.
form - Render a form suitable for submission to a Struts Action

Render an HTML form element containing the nested components to present the appropriate label and input field elements. This tag is distinguished from the tag in the standard HTML RenderKit because it accepts a Struts <action> path as a parameter, instead of a generic form name.

Attribute NameDescription
action

Struts Action to which this form should be submitted. This value must exactly match the path attribute of the corresponding <action> element in the struts-config.xml configuration file for this application module.

[Required]
enctype

The content encoding to be used to submit this form, if the method is POST. This must be set to "multipart/form-data" if your form includes file upload field(s). If not specified, the browser default ("application/x-www-form-urlencoded") is used.

focus

The identifier of the form field that should receive focus when this form is rendered.

focusIndex

If the focus field is an array, such as a radio button group, you can specify the index of the array element to receive focus.

id Component id of this component.
method

Method by which this form submit will occur (GET, POST). If not specified, POST is used.

onreset

JavaScript event handler executed if this form is reset.

onsubmit

JavaScript event handler executed if this form is submitted.

rendered Boolean attribute indicating whether this component should be rendered or not.
style

CSS styles to be applied to this HTML element.

styleClass CSS style class to use when rendering this component.
styleId

Identifier to be assigned to this HTML element (renders an "id" element).

target

Window target to which this form is submitted, such as for use in framed presentations.

html - Render an HTML <html> element

Renders an HTML <html> element with language attributes extracted from the user's current Locale object, if there is one.

Attribute NameDescription
id Component id of this component.
locale

Set to true in order to record a Locale based on the current request's Accept-Language header (if any), if none has currently been set.

xhtml

Set to true to render an xml:lang element on the generated html element. It also causes nested Struts HTML tags (although not JavaServer Faces component tags) to render themselves as xhtml.

javascript - Render JavaScript validation based on the validation rules loaded by the ValidatorPlugIn.

IMPLEMENTATION NOTE - Unlike other tags in this tag library, this does not correspond to a JavaServer Faces user interface component. It simply shares the tag implementation class from the struts-html tag library.

Render JavaScript validation based on the validation rules loaded by the ValidatorPlugIn. The set of validation rules that should be generated is based on the formName attribute passed in, which should match the name attribute of the form element in the xml file.

The dynamicJavascript and staticJavascript attributes default to true, but if dynamicJavascript is set to true and staticJavascript is set to false then only the dynamic JavaScript will be rendered. If dynamicJavascript is set to false and staticJavascript is set to true then only the static JavaScript will be rendered which can then be put in separate JSP page so the browser can cache the static JavaScript.

Attribute NameDescription
cdata

If set to "true" and XHTML has been enabled, the JavaScript will be wrapped in a CDATA section to prevent XML parsing. The default is "true" to comply with the W3C's recommendation.

[RT Expr]
dynamicJavascript

Whether or not to render the dynamic JavaScript. Defaults to true.

formName

The key (form name) to retrieve a specific set of validation rules.

[RT Expr]
htmlComment

Whether or not to enclose the javascript with HTML comments. This attribute is ignored in XHTML mode because the script would be deleted by the XML parser. See the cdata attribute for details on hiding scripts from XML parsers. Defaults to true.

[RT Expr]
method

The alternate JavaScript method name to be used instead of the of the default. The default is 'validate' concatenated in front of the key (form name) passed in (ex: validateRegistrationForm).

[RT Expr]
page

The current page of a set of validation rules if the page attribute for the field element in the xml file is in use.

[RT Expr]
src

The src attribute's value when defining the html script element.

[RT Expr]
staticJavascript

Whether or not to render the static JavaScript. Defaults to true.

message - Render a localized message looked up from a message resources bundle

Render the message text looked up from a message resources bundle, based on our current locale. The message key must be specified by exactly one of the following attributes:

  • key - Message key is specified directly.
  • valueRef - Retrieve the value of the specified value reference, convert it to a String, and use that as the requested message key.

The MessageResources bundle to be used is specified by the bundle attribute, as follows:

  • If bundle is present, it is the name of the servlet context attribute under which our MessageResources bundle should be retrieved.
  • If bundle is not present, use the default MessageResources bundle for the current subapp.

Substitution parameters for the message may be nested inside this tag by using the parameter tag from the standard HTML RenderKit tag library.

Attribute NameDescription
bundle

Name of the servlet context attribute under which the desired MessageResources bundle is stored. If not specified, the default bundle for this sub-application will be used.

id

Component identifier of the component corresponding to this tag.

key

Literal value of the message key to look up. Exactly one of key and valueRef must be specified.

rendered Boolean attribute indicating whether this component should be rendered or not.
styleClass

Name of the CSS style class used to render this component.

valueRef

Value reference expression used to retrieve a dynamic value for the message key to look up. Exactly one of key and valueRef must be specified.

stylesheet - Render an HTML <link> relative reference to a stylesheet

Renders an HTML <link> element with a relative reference to a text/css stylesheet at the specified context-relative path.

Attribute NameDescription
id Component id of this component.
path Context-relative path to the resource for this relative link. [Required]
rendered Boolean attribute indicating whether this component should be rendered or not.
write - Render the value of the specified model object or text string

Render the text associated with the specified model object or text string, optionally performing filtering and formatting tasks described by the optional attributes described below. The text to be rendered is specified in exactly one of the following attributes:

  • value - The literal text value to be rendered.
  • valueRef - An expression language reference to retrieve the text to be rendered.

Additional control over the rendering process is specified by the following optional attributes, with default values as indicated:

  • filter - Set to true to filter the rendered text for characters that are sensitive in HTML, or false to skip filtering. By default, rendered text is filtered.
Attribute NameDescription
filter

Should we filter the output for characters that are sensitive in HTML? The default value is true.

id

Component identifier of the component corresponding to this tag.

rendered Boolean attribute indicating whether this component should be rendered or not.
styleClass

Name of the CSS style class used to render this component.

value

Literal text to be rendered.

valueRef

Value reference expression for use in retrieving the text to be rendered.


Copyright (c) 2003, Apache Software Foundation