
org.apache.strutsel.package.html Maven / Gradle / Ivy
Package Documentation for org.apache.strutsel Package
The "Struts-EL" library
contains a set of tag libraries, all of whose classes are derived from
classes in the Struts tag libraries. The Struts-EL tags all implement the
same attributes as their counterparts in the base Struts tag libraries.
The
difference provided by Struts-EL is that the tag attribute values are not
evaluated as run-time scriptlets (sometimes called "rtexprvalue"s), but
are
instead evaluated by the expression language engine in the JavaServer
Pages
Standard Tag Library (often called the JSTL).
Introduction
The Struts-EL library is intended to be used alongside the Struts library,
and with the JSTL. In the development of the Struts-EL library, each tag
in
the Struts tag libraries was examined to see if all of its functionality
is
covered in an existing tag in the JSTL. If this was the case, then it was
decided to not include a version of this tag in the
Struts-EL library. The tags that were "ported" to Struts-EL were deemed to
have functionality which the JSTL could not directly cover.
The rest of this package description will briefly review the Struts tags
which were not ported to the Struts-EL library (or which
were "on the bubble", and why. The detailed package descriptions for each
section of the library (html-el, logic-el, and bean-el) will demonstrate
in
detail the usage of the Struts-EL tags, focusing on attribute value
evaluation issues. Details of the operation of these tags in the Struts
framework can be learned from the package descriptions and documentation
for
the base Struts library.
HTML-EL tag library
This is a short section. The JSTL does not include any functionality for
generating HTML elements, thus every tag in the "struts-html" tag library was
ported to the "struts-html-el" tag library.
Logic-EL tag library
The following table lists the "struts-logic" tags which were not ported to
the "struts-logic-el" tag library, including which JSTL elements or
features
will provide that functionality. Examples after the table will demonstrate
these.
Struts-Logic tag
JSTL tags or feature
empty
c:if, c:when, EL
equal
c:if, c:when, EL
greaterEqual
c:if, c:when, EL
greaterThan
c:if, c:when, EL
lessEqual
c:if, c:when, EL
lessThan
c:if, c:when, EL
notEmpty
c:if, c:when, EL
notEqual
c:if, c:when, EL
The following are some examples of "Before" and "After", where the first
example is pure Struts usage, and the second example will be pure JSTL
usage, not involving Struts-EL at all.
Struts Example:
<logic:empty name="foo" property="stuff">
Some stuff
</logic:empty>
JSTL Version:
<c:if test="${empty foo.stuff}">
Some stuff
</c:if>
Struts Example:
<logic:notEmpty name="foo" property="stuff">
Some stuff
</logic:notEmpty>
JSTL Version:
<c:if test="${!empty foo.stuff}">
Some stuff
</c:if>
Struts Example:
<logic:equal name="foo" property="stuff" value="<%=thing.getStuff()%>">
Some stuff
</logic:equal>
JSTL Version:
<%-- Assumes "thing" is a scoped variable --%>
<c:if test="${foo.stuff eq thing.stuff}">
Some stuff
</c:if>
Struts Example:
<logic:greaterThan name="foo" property="stuff" value="<%=thing.getStuff()%>">
Some stuff
</logic:empty>
JSTL Version:
<%-- Assumes "thing" is a scoped variable --%>
<c:if test="${foo.stuff ge thing.stuff}">
Some stuff
</c:if>
Struts Example:
<logic:present cookie="shoppingCart">
Some stuff
</logic:present>
JSTL Version:
<c:if test='${!empty cookie["shoppingCart"]}">
Some stuff
</c:if>
Struts Example:
<logic:present header="User-Agent">
Some stuff
</logic:present>
JSTL Version:
<c:if test='${!empty header["User-Agent"]}">
Some stuff
</c:if>
Bean-EL tag library
The following table lists the "struts-bean" tags which were not ported to
the "struts-bean-el" tag library, including which JSTL elements or
features
will provide that functionality. Examples after the table will demonstrate
these.
Struts-Bean tag
JSTL tags or feature
cookie
c:set, EL
define
c:set, EL
header
c:set, EL
include
c:import
parameter
c:set, EL
write
c:out
Note that the "bean:resource" Struts tag is similar, at least
superficially,
to the functionality of the "c:import" tag, but "bean:resource"
was ported to the Struts-EL library. This is because
resources requested through the "c:import" tag may be processed through a
mapped servlet, preventing direct access to the resource. The
"bean:resource" tag allows direct access to the resource, without an
intervening servlet. For instance, if it is desired to obtain the raw text
of a JSP page, using "c:import" will not work, because the JSP page will
be
processed by the JSP servlet. However, using "bean:resource" will retrieve
just the text of the JSP page, if that is desired.
Also note that some functionality of the "bean:include" tag, which was not
ported to the Struts-EL library, is not available in the JSTL. This
includes the ability to specify the name of a Struts forward, and the
ability to include the current transaction control token. These features
will be addressed in a future minor release of Struts-EL.
The following are some examples of "Before" and "After", where the first
example is pure Struts usage, and the second example will be pure JSTL
usage, not involving Struts-EL at all.
Struts Example:
<bean:cookie id="cookieVal" name="stuff"/>
JSTL Version:
<c:set var="cookieVal" value='${cookie["stuff"]}'/>
Struts Example:
<bean:define id="thing" name="foo" property="stuff"/>
JSTL Version:
<c:set var="thing" value="${foo.stuff}"/>
Struts Example:
<bean:header id="headerVal" name="stuff"/>
JSTL Version:
<c:set var="headerVal" value='${header["stuff"]}'/>
Struts Example:
<bean:include id="stuffOut"
href="http://somewhere.com/stuff.jsp"/>
JSTL Version:
<c:import var="stuffOut"
value="http://somewhere.com/stuff.jsp"/>
Struts Example:
<bean:parameter id="parameterVal" name="stuff"/>
JSTL Version:
<c:set var="parameterVal" value='${param["stuff"]}'/>