Define a scripting variable based on the value(s) of the specified bean property.
Attributes
id
name
scope attribute (if property
is also specified) or the attribute name of the bean that is duplicated with
the new reference created by this tag (if property is not
also specified). This attribute is required unless you specify a
value attribute or nested body content.
property
name. This value may be a simple, indexed,
or nested property reference expression. If not specified, the bean
identified by name is given a new reference identified by id
.
scope
PageContext.findAttribute() are applied.
toScope
scope
.
type
id attribute.
value
java.lang.String value to which the exposed bean
should be set. This attribute is required unless you specify the
name attribute or nested body content.
Attributes
toScope
property, if any), and a corresponding scripting variable, both of which
are named by the value of the id attribute. The corresponding
value to which this new attribute (and scripting variable) is set are
specified via use of exactly one of the following approaches (trying to
use more than one will result in a JspException being thrown):
Specify a name attribute (plus optional property
and scope attributes) - The created attribute and scripting
variable will be of the type of the retrieved JavaBean property,
unless it is a Java primitive type, in which case it will be wrapped
in the appropriate wrapper class (i.e. int is wrapped by
java.lang.Integer).
Specify a value attribute - The created attribute and
scripting variable will be of type java.lang.String,
set to the value of this attribute.
Specify nested body content - The created attribute and scripting
variable will be of type java.lang.String, set to the
value of the nested body content.
If a problem occurs while retrieving the specified bean property, a request time exception will be thrown.
The <bean:define> tag differs from <jsp:useBean>
in several ways, including:
Unconditionally creates (or replaces) a bean under the specified identifier.
Can create a bean with the value returned by a property getter of a different bean (including properties referenced with a nested and/or indexed property name).
Can create a bean whose contents is a literal string (or the result
of a runtime expression) specified by the value
attribute.
Does not support nested content (such as <jsp:setProperty>
tags) that are only executed if a bean was actually created.
Note: There is a restriction in the JSP 1.1
Specification that disallows using the same value for an id attribute
more than once in a single JSP page. Therefore, you will not be able to
use <bean:define> for the same bean name more than
once in a single page.
For more information about Bean creation differences, as well as alternative approaches to introducing beans into a JSP page, see the Bean Developer's Guide section on the Apache Organization web site at http://struts.apache.org/api/org/apache/struts/taglib/bean/package-summary.html#doc.Creation .
About the Struts Custom
Tag Libraries in JDeveloper
Reference: Struts Tag Libraries
Reference: Struts Bean Tag Library
Copyright © 1997, 2004, Oracle. All rights reserved.