Skip to main content
This revision made August 09, 2011 00:19, by Kin-man Chung
« earlier revision revert to this « later revision

Static Fields and Methods

Syntax

The syntax "T(className)" where className is of the form id("." id)* denotes a Java class at parse time. This by itself is not evaluated and does not produce a value. When followed by .id, the construct T(className).id denotes and evaluates to a static field or method (of the name id) of a class. For instance,

    #{T(java.lang.Boolean).TRUE}

evaluates to the static field java.lang.Boolean.TRUE.

As a special case, with the id "class", the construct T(className).class evaluates to the "java.lang.Class" instance of the class. For instance,

    #{T(java.lang.Boolean).class}

evaluates to the java.lang.Boolean.class instance.

The same syntax is used for Enum constants. For instance,

    #{T(org.acme.Color).RED}

evaluates to the Enum constant org.acme.Color.RED.

Note New reserved word: T

Imports

A class can be imported before it is referenced. ELManager provides two methods importClass() and importPackage(). See the javadoc in ELManager for details.

An imported class can be referenced by its class name (without the package). For instance,

    #{T(Boolean).TRUE}

The package java.lang is imported by default.

Since class and package imports affects how expressions are evaluated, they should be included in ELContext. A new class ImportHandler is added to the API and ELContext adds a reference to it. See the javadocs for details.

ImportHandler.java

see

ELManager.java

see

ELContext.java

see

StandardELContext.java

see

Difference compared to previous revision
<span> #{T(org.acme.Color).RED} evaluates to the Enum constant org.acme.Color.RED.<span style="text-decoration:underline;color:green">'''Note''' New reserved word: T </span>=== Imports=== A class can be imported before it is referenced. ELManager provides two methods importClass() and importPackage(). See the javadoc in ELManager for details.<span>
 
 
Close
loading
Please Confirm
Close