package-summary.html

来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 459 行 · 第 1/2 页

HTML
459
字号
in its own specification document within the JavaServer Pages (tm) (JSP) 2.1 specification, but does not have any dependencies on any portion of the JSP 2.1 specification. It is intended for general use outside ofthe JSP and JSF specifications as well.</p><p>This package contains the classes and interfaces that describeand define the programmatic access to the Expression Language engine. The APIis logically partitioned as follows:<ul>  <li><a href="#Context">EL Context</a></li>  <li><a href="#ExpressionObjects">Expression Objects</a></li>  <li><a href="#ExpressionCreation">Creation of Expressions</a></li>  <li><a href="#Resolver">Resolution of Model Objects and their Properties</a></li>  <li><a href="#Functions">EL Functions</a></li>  <li><a href="#Variables">EL Variables</a></li></ul><h3><a name="Context">EL Context</a></h3><p>An important goal of the EL is to ensure it can be used in a variety of environments. It must therefore provide enough flexibilityto adapt to the specific requirements of the environment where it isbeing used.</p><p>Class <A HREF="../../javax/el/ELContext.html" title="class in javax.el"><CODE>ELContext</CODE></A> is what links the EL with the specific environment where it is being used.It providesthe mechanism through which all relevant context for creating orevaluating an expression is specified.</p><p>Creation of <code>ELContext</code> objects is controlled through  the underlying technology. For example, in JSP, the <code>JspContext.getELContext()</code> factory method is used.</p>  <p>Some technologies provide the ability to add an <A HREF="../../javax/el/ELContextListener.html" title="interface in javax.el"><CODE>ELContextListener</CODE></A> so that applications and frameworks can ensure their own context objects are attached to any newly created <code>ELContext</code>.</p> <h3><a name="ExpressionObjects">Expression Objects</a></h3><p>At the core of the Expression Language is the notion of an <i>expression</i>that gets parsed according to the grammar defined by the Expression Language.</p><p>There are two types of expressions defined by the EL: <i>value expressions</i>and <i>method expressions</i>. A <A HREF="../../javax/el/ValueExpression.html" title="class in javax.el"><CODE>ValueExpression</CODE></A> such as <code>"${customer.name}"</code> can be used eitheras an <i>rvalue</i> (return the value associated with property <code>name</code>of the model object <code>customer</code>) or as an <i>lvalue</i> (set the value of the property <code>name</code> of the model object<code>customer</code>).</p><p>A <A HREF="../../javax/el/MethodExpression.html" title="class in javax.el"><CODE>MethodExpression</CODE></A> such as <code>"${handler.process}"</code> makes it possible to invoke a method (<code>process</code>) on a specific model object (<code>handler</code>).</p><p>All expression classes extend the base class <A HREF="../../javax/el/Expression.html" title="class in javax.el"><CODE>Expression</CODE></A>, making themserializable and forcing them to implement <code>equals()</code> and <code>hashCode()</code>. Morevover, each method on these expression classes that actually evaluates an expression receives a parameterof class <A HREF="../../javax/el/ELContext.html" title="class in javax.el"><CODE>ELContext</CODE></A>,which provides the context required to evaluate the expression.</p><h3><a name="ExpressionCreation">Creation of Expressions</a></h3><p>An expression is created through the <A HREF="../../javax/el/ExpressionFactory.html" title="class in javax.el"><CODE>ExpressionFactory</CODE></A> class.The factory provides two creation methods; one for each type of expression supported by the EL.</p><p>To create an expression, one must provide an <A HREF="../../javax/el/ELContext.html" title="class in javax.el"><CODE>ELContext</CODE></A>, a string representing the expression, and the expected type (<code>ValueExpression</code>) or signature (<code>MethodExpression</code>). The <code>ELContext</code> provides the context necessary to parse an expression.Specifically, if the expression uses an EL function (for example <code>${fn:toUpperCase(customer.name)}</code>) or anEL variable, then  <A HREF="../../javax/el/FunctionMapper.html" title="class in javax.el"><CODE>FunctionMapper</CODE></A> and <A HREF="../../javax/el/VariableMapper.html" title="class in javax.el"><CODE>VariableMapper</CODE></A>objects must be available within the <code>ELContext</code> so that EL functions andEL variables are properly mapped.</p><h3><a name="Resolver">Resolution of Model Objects and their Properties</a></h3><p>Through the <A HREF="../../javax/el/ELResolver.html" title="class in javax.el"><CODE>ELResolver</CODE></A> base class, the EL features a pluggable mechanism to resolve model object references as well as properties of these objects.</p><p>The EL API provides implementations of <code>ELResolver</code> supporting property resolution for common data types which includearrays (<A HREF="../../javax/el/ArrayELResolver.html" title="class in javax.el"><CODE>ArrayELResolver</CODE></A>), JavaBeans (<A HREF="../../javax/el/BeanELResolver.html" title="class in javax.el"><CODE>BeanELResolver</CODE></A>), <code>List</code>s (<A HREF="../../javax/el/ListELResolver.html" title="class in javax.el"><CODE>ListELResolver</CODE></A>), <code>Map</code>s (<A HREF="../../javax/el/MapELResolver.html" title="class in javax.el"><CODE>MapELResolver</CODE></A>), and <code>ResourceBundle</code>s (<A HREF="../../javax/el/ResourceBundleELResolver.html" title="class in javax.el"><CODE>ResourceBundleELResolver</CODE></A>).</p><p>Tools can easily obtain more information about resolvable model objects and their resolvable properties by callingmethod <code>getFeatureDescriptors</code> on the <code>ELResolver</code>. This method exposes objectsof type <code>java.beans.FeatureDescriptor</code>, providing all information of interest on top-level model objects as well as their properties.</p> <h3><a name="Functions">EL Functions</a></h3><p>If an EL expression uses a function (for example <code>${fn:toUpperCase(customer.name)}</code>), then a <A HREF="../../javax/el/FunctionMapper.html" title="class in javax.el"><CODE>FunctionMapper</CODE></A> object must also be specified within the <code>ELContext</code>. The <code>FunctionMapper</code> is responsible to map <code>${prefix:name()}</code> style functions to static methods that can execute the specified functions. </p><h3><a name="Variables">EL Variables</a></h3><p>Just like <A HREF="../../javax/el/FunctionMapper.html" title="class in javax.el"><CODE>FunctionMapper</CODE></A> providesa flexible mechanism to add functions to the EL, <A HREF="../../javax/el/VariableMapper.html" title="class in javax.el"><CODE>VariableMapper</CODE></A>provides a flexible mechanism to support the notion of <strong>EL variables</strong>.</p> <p>An EL variable does not directly refer to a model object that can thenbe resolved by an <code>ELResolver</code>. Instead, it refers to an ELexpression. The evaluation of that EL expression gives the EL variableits value.</p><p>For example, in the following code snippet<blockquote>  <code>&lt;h:inputText value="#{handler.customer.name}"/></code></blockquote><code>handler</code> refers to a model object that can be resolved by an EL Resolver.</p><p>However, in this other example:<blockquote><pre>&lt;c:forEach var="item" items="#{model.list}">   &lt;h:inputText value="#{item.name}"/>&lt;/c:forEach></pre></blockquote><code>item</code> is an EL variable because it does not refer directly to a modelobject.  Instead, it refers to another EL expression, namely aspecific item in the collection referred to by the EL expression<code>#{model.list}<code>.</p><p>Assuming that there are three elements in <code>${model.list}</code>, this meansthat foreach invocation of <code>&lt;h:inputText></code>, the following information about <code>item</code> must be preserved in the <A HREF="../../javax/el/VariableMapper.html" title="class in javax.el"><CODE>VariableMapper</CODE></A>:<blockquote>    first invocation: <code>item</code> maps to first element in <code>${model.list}</code><br>    second invocation: <code>item</code> maps to second element in <code>${model.list}</code><br>    third invocation: <code>item</code> maps to third element in <code>${model.list}</code><br></blockquote><p><code>VariableMapper</code> provides the mechanisms required to allow the mappingof an EL variable to the EL expression from which it gets its value.</p><P><P><DL></DL><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../javax/ejb/spi/package-summary.html"><B>PREV PACKAGE</B></A>&nbsp;&nbsp;<A HREF="../../javax/enterprise/deploy/model/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html?javax/el/package-summary.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="package-summary.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><font size="-1"><a href="http://java.sun.com/webapps/bugreport">Submit a bug or feature</a> <p>Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to <a href="../legal/license.html" target="_top">license terms.</a></font></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?