Oracle JavaServer Pages Developer's Guide and Reference Release 8.1.7 Part Number A83726-01 |
|
This section describes Oracle-specific bean reference syntax and expression syntax supported by the compile-time JML implementation, for specifying tag attribute values. The following topics are covered:
This functionality is not portable to other JSP environments.
Generally speaking, a bean reference is any reference to a JavaBean instance (bean) that results in accessing either a property or a method of the bean. This includes a reference to a property or method of a bean where the bean itself is a property of another bean.
This becomes cumbersome, because standard JavaBeans syntax requires that properties be accessed by calling their accessor methods rather than by direct reference. For example, consider the following direct reference:
a.b.c.d.doIt()
This must be expressed as follows in standard JavaBeans syntax:
a.getB().getC().getD().doIt()
Oracle's compile-time JML implementation, however, offers abbreviated syntax.
Oracle-specific syntax supported by the compile-time JML implementation allows bean references to be expressed using direct "." (dot) notation. Note that standard bean property accessor method syntax is also still valid.
Consider the following standard JavaBean reference:
customer.getName()
In JML bean reference syntax, you can express this in either of the following ways:
customer.getName()
or:
customer.name
JavaBeans can optionally have a default property, whose reference is assumed if no reference is explicitly stated. Default property names can be omitted in JML bean references. In the example above, if name
is the default property, then the following are all valid JML bean references:
customer.getName()
or:
customer.name
or simply:
customer
Most JavaBeans do not define a default property. Of those that do, the most significant are the JML datatype JavaBeans described in "JML Extended Datatypes".
JML expression syntax supported by the compile-time JML implementation is a superset of standard JSP expression syntax, adding support for the JML bean reference syntax documented in the preceding section.
A JML bean reference appearing in a JML expression must be enclosed in the following syntax:
$[JML_bean_reference]
Tag attribute documentation under "JSP Markup Language (JML) Tag Descriptions" notes standard syntax that is portable. You can set attributes, as documented there, for either the runtime or the compile-time JML implementation and even for non-Oracle JSP environments.
If you intend to use only the Oracle-specific compile-time implementation, however, you can set attributes using JML bean references and JML expression syntax, as documented in "JML Bean References and Expressions, Compile-Time Implementation".
Note the following:
$[...]
syntax inside standard JSP <%=...%>
syntax.
Consider an example using the JML useVariable
tag. You would use syntax such as the following for the runtime implementation:
<jml:useVariable id = "isValidUser" type = "boolean" value = "<%= dbConn.isValid() %>" scope = "session" />
You can alternatively use syntax such as the following for the compile-time implementation (the value
attribute can be either a string literal or an expression):
<jml:useVariable id = "isValidUser" type = "boolean" value = "<%= $[dbConn.valid] %>" scope = "session" />
$[...]
syntax without being nested in <%=...%>
syntax.
Consider an example using JML choose...when
tags. You would use something such as the following syntax for the runtime implementation (presume orderedItem
is a JmlBoolean
instance):
<jml:choose> <jml:when condition = "<%= orderedItem.getValue() %>" > You have changed your order: -- outputs the current order -- </jml:when> <jml:otherwise> Are you sure we can't interest you in something? </jml:otherwise> </jml:choose>
You can alternatively use syntax such as the following for the compile-time implementation (the condition
attribute can be an expression only):
<jml:choose> <jml:when condition = "$[orderedItem]" > You have changed your order: -- outputs the current order -- </jml:when> <jml:otherwise> Are you sure we can't interest you in something? </jml:otherwise> </jml:choose>
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|