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
commandLink Render an HTML hyperlink that submits the current form
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.
loadMessages Expose a MessageResources instance as a Map
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
binding

Value binding expression to bind this component to a backing bean property.

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.
commandLink - Render an HTML hyperlink that submits the current form

Renders an HTML <a> element defining a hyperlink that submits the current form. This component is required because the JSF 1.0 and 1.1 specifications require interoperability between the renderers for the form element and the command link element, without providing a portable mechanism to allow intermixed libraries.

Attribute NameDescription
action
actionListener
id
immediate
rendered
value
accesskey
charset
dir
hreflang
lang
onblur
onclick
ondblclick
onfocus
onkeydown
onkeypress
onkeyup
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
rel
rev
style
styleClass
tabindex
target
title
type
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
binding

Value binding expression to bind this component to a backing bean property.

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.
property Component of the component for which to render errors. If not specified, all messages (regardless of property) are displayed.
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, and triggers the creation of a Struts form bean if needed.

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]
binding

Value binding expression to bind this component to a backing bean property.

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.
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.
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
binding

Value binding expression to bind this component to a backing bean property.

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.

rendered Boolean attribute indicating whether this component should be rendered or not.
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 is based on the tag implementation class used in 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.

loadMessages - Expose a MessageResources instance as a Map

Create a Map wrapping the specified MessageResources instance, which will return localized messages based on the Locale stored in the view root component of the current view.

Attribute NameDescription
messages

Application scope key containing the MessageResources instance to be exposed. If not specified, the default MessageResources instance for the current application module is exposed.

var

Request scope key under which the Map will be stored.

[Required]
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.
  • value - 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.

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
binding

Value binding expression to bind this component to a backing bean property.

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.

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.

key

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

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

CSS styles used to render this component.

styleClass

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

value

Value reference expression used to retrieve a dynamic value for the message key to look up. Exactly one of key and value 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
binding

Value binding expression to bind this component to a backing bean property.

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 or a value reference expression 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
binding

Value binding expression to bind this component to a backing bean property.

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.
style

CSS styles used to render this component.

styleClass

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

value

Literal text to be rendered, or value reference expression to retrieve the text to be rendered.


Copyright (c) 2003-2004, The Apache Software Foundation