Oracle JavaServer Pages Developer's Guide and Reference Release 8.1.7 Part Number A83726-01 |
|
This section presents the following:
Most JML tags are available in both the runtime model and the compile-time model; however, there are exceptions, as summarized in Table C-1.
This section provides detailed descriptions of JML tags that are still supported by the JML compile-time implementation, but are not supported by the JML runtime implementation. These tags are not documented under "JSP Markup Language (JML) Tag Descriptions".
In summary, this consists of the following JML tags.
For the syntax documentation in the tag descriptions, note the following:
[...]
taglib
directive.
This tag declares an object to be used in the page, locating the previously instantiated object at the specified scope by name if it exists. If it does not exist, the tag will create a new instance of the appropriate class and attach it to the specified scope by name.
The syntax and semantics are the same as for the standard jsp:useBean
tag, except that wherever a JSP expression is valid in jsp:useBean
usage, either a JML expression or a JSP expression is valid in JML useBean
usage.
<jml:useBean id = "beanInstanceName" scope ="page | request | session | application" class ="package.class" | type = "package.class" | class ="package.class" type = "package.class" | beanName = "package.class | <%= jmlExpression %>" type = "package.class" />
Alternatively, you can have additional nested tags, such as setProperty
tags, and use a </jml:useBean>
end tag.
Refer to the Sun Microsystems JavaServer Pages Specification, Version 1.1 for information about attributes and their syntax.
<jml:useBean id = "isValidUser" class = "oracle.jsp.jml.JmlBoolean" scope = "session" />
This tag is functionally identical to the standard jsp:getProperty
tag. It prints the value of the bean property into the response.
For general information about getProperty
usage, refer to the Sun Microsystems JavaServer Pages Specification, Version 1.1.
<jml:getProperty name = "beanInstanceName" property = "propertyName" />
name
--This is the name of the bean whose property is being retrieved. This attribute is required.
property
--This is the name of the property being retrieved. This attribute is required.
The following example outputs the current value of the salary
property. (Assume salary
is of type JmlNumber
.)
<jml:getProperty name="salary" property="value" />
This is equivalent to the following:
<%= salary.getValue() %>
This tag covers the functionality supported by the standard jsp:setProperty
tag, but also adds functionality to support JML expressions. In particular, you can use JML bean references.
For general information about setProperty
usage, refer to the Sun Microsystems JavaServer Pages Specification, Version 1.1.
<jml:setProperty name = "beanInstanceName" property = " * " | property = "propertyName" [ param = "parameterName" ] | property = "propertyName" value = "stringLiteral | <%= jmlExpression %>" />
name
--This is the name of the bean whose property is being set. This attribute is required.
property
--This is the name of the property being set. This attribute is required.
value
--This is an optional parameter that lets you set the value directly instead of from a request parameter. The JML setProperty
tag supports JML expressions in addition to standard JSP expressions to specify the value.
The following example updates salary
with a six percent raise. (Assume salary
is of type JmlNumber
.)
<jml:setProperty name="salary" property="value" value="<%= $[salary] * 1.06 %>" />
This is equivalent to the following:
<% salary.setValue(salary.getValue() * 1.06); %>
This tag provides an alternative for setting a bean property, using syntax that is more convenient than that of the setProperty
tag.
<jml:set name = "beanInstanceName.propertyName" value = "stringLiteral | <%= jmlExpression %>" />
name
--This is a direct reference (JML bean reference) to the bean property to be set. This attribute is required.
value
--This is the new property value. It is expressed either as a string literal, a JML expression, or a standard JSP expression. This attribute is required.
Each of the following examples updates salary
with a six percent raise. (Assume salary
is of type JmlNumber
.)
<jml:set name="salary.value" value="<%= salary.getValue() * 1.06 %>" />
or:
<jml:set name="salary.value" value="<%= $[salary.value] * 1.06 %>" />
or:
<jml:set name="salary" value="<%= $[salary] * 1.06 %>" />
These are equivalent to the following:
<% salary.setValue(salary.getValue() * 1.06); %>
This tag provides a mechanism to invoke bean methods that return nothing.
<jml:call method = "beanInstanceName.methodName(parameters)" />
method
--This is the method call as you would write it in a scriptlet, except that the beanInstancename.methodName
portion of the statement can be written as a JML bean reference if enclosed in JML expression $[... ]
syntax. This attribute is required.
The following example redirects the client to a different page:
<jml:call name='response.sendRedirect("http://www.oracle.com/")' />
This is equivalent to the following:
<% response.sendRedirect("http://www.oracle.com/"); %>
This tag allows controlled, synchronous access to the named object for any code that uses it within the tag body.
Generally, JSP developers need not be concerned with concurrency issues. However, because application-scoped objects are shared across all users running the application, access to critical data must be controlled and coordinated.
You can use the JML lock
tag to prevent concurrent updates by different users.
<jml:lock name = "beanInstanceName" > ...body... </jml:lock>
name
--This is the name of the object that should be locked during execution of code in the lock
tag body. This is a required attribute.
In the following example, pageCount
is an application-scoped JmlNumber
value. The variable is locked to prevent the value from being updated by another user between the time this code gets the current value and the time it sets the new value.
<jml:lock name="pageCount" > <jml:set name="pageCount.value" value="<%= pageCount.getValue() + 1 %>" /> </jml:lock>
This is equivalent to the following:
<% synchronized(pageCount) { pageCount.setValue(pageCount.getValue() + 1); } %>
This tag includes the output of another JSP page, a servlet, or an HTML page in the response of this page (the page invoking the include
). It provides the same functionality as the standard jsp:include
tag except that the page
attribute can also be expressed as a JML expression.
<jml:include page = "relativeURL | <%= jmlExpression %>" flush = "true" />
For general information about include
attributes and usage, refer to the Sun Microsystems JavaServer Pages Specification, Version 1.1.
The following example includes the output of table.jsp
, a presentation component that renders an HTML table, based on data in the query string and request attributes.
<jml:include page="table.jsp?maxRows=10" flush="true" />
This tag forwards the request to another JSP page, a servlet, or an HTML page. It provides the same functionality as the standard jsp:forward
tag except that the page
attribute can also be expressed as a JML expression.
<jml:forward page = "relativeURL | <%= jmlExpression %>" />
For general information about forward
attributes and usage, refer to the Sun Microsystems JavaServer Pages Specification, Version 1.1.
<jml:forward page="altpage.jsp" />
This tag provides essentially the same functionality as a standard JSP expression: <%=
expr
%>
. A specified JML expression or string literal is evaluated, and the result is output into the response. With this tag, the JML expression does not have to be enclosed in <%= ... %>
syntax; however, a string literal must be enclosed in double-quotes.
<jml:print eval = '"stringLiteral"' | "jmlExpression" />
eval
--Specifies the string or expression to be evaluated and output. This attribute is required.
Either of the following examples outputs the current value of salary
, which is of type JmlNumber
:
<jml:print eval="$[salary]"/>
or:
<jml:print eval="salary.getValue()" />
The following example prints a string literal:
<jml:print eval='"Your string here"' />
This tag has functionality identical to that of the standard jsp:plugin
tag.
For information about plugin
attributes, usage, and examples, refer to the Sun Microsystems JavaServer Pages Specification, Version 1.1.
|
Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|