Core Methods
This section describes the EL functions defined in the built-in TLD called
http://www.zkoss.org/dsp/web/core. Declare the taglib once, then call any
function with its prefix:
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<window title="${c:l('app.title')}">
...
</window>
The table below lists every core function with its signature and purpose; click a name for full details, parameters, and examples.
| Function | Signature | Description |
|---|---|---|
| attr | String attr(String name, Object value) |
Generates an HTML/XML attribute name="value"; empty value yields "". |
| boolean | boolean boolean(Object value) |
Converts an object to a boolean. |
| browser | boolean browser(String type) |
Tests whether the current request comes from a browser of the given type. |
| cat | String cat(String s1, String s2) |
Concatenates two strings (null treated as empty). |
| cat3 | String cat3(String s1, String s2, String s3) |
Concatenates three strings. |
| cat4 | String cat4(String s1, ..., String s4) |
Concatenates four strings. |
| cat5 | String cat5(String s1, ..., String s5) |
Concatenates five strings. |
| char | char char(Object value) |
Converts an object to a character. |
| class | Class class(String className) |
Returns the class for the given class name. |
| decimal | BigDecimal decimal(Object value) |
Converts an object to a BigDecimal. |
| eatQuot | String eatQuot(String s) |
Removes single and double quotes to avoid JavaScript injection. |
| encodeThemeURL | String encodeThemeURL(String url) |
Encodes a URL with the theme-specific prefix and session info. |
| encodeURIComponent | String encodeURIComponent(String s) |
HTTP-encodes a URI query parameter (e.g. / → %2F). |
| encodeURL | String encodeURL(String uri) |
Encodes a URL, resolving * to the current locale/browser. |
| endsWith | boolean endsWith(String value, String suffix) |
Tests whether the string ends with the suffix. |
| escapeXML | String escapeXML(String s) |
Escapes special characters to be HTML/XML-safe (< → <, …). |
| formatDate | String formatDate(Date date, String pattern) |
Formats a Date into a string with the given pattern. |
| formatNumber | String formatNumber(Object number, String pattern) |
Formats a number into a string with the given pattern. |
| getCurrentLocale | Locale getCurrentLocale() |
Returns the locale of the current request; never null. |
| indexOf | int indexOf(Object value, Object element) |
The first index of the element within the value. |
| int | int int(Object value) |
Converts an object to an int. |
| isInstance | boolean isInstance(Object class, Object value) |
Tests whether the value is an instance of the given class. |
| join | String join(Object[] value, String separator) |
Joins an array into a string with the separator. |
| l | String l(String key) |
Returns the i18n label for the key (current locale). |
| l2 | String l2(String key, Object[] args) |
Returns the i18n label for the key and formats it with args. |
| lastIndexOf | int lastIndexOf(Object value, Object element) |
The last index of the element within the value. |
| length | int length(Object value) |
The length of a string, array, collection, or map. |
| new | Object new(Object cls) |
Instantiates a class via its default constructor. |
| new1 | Object new1(Object cls, Object arg) |
Instantiates a class with one constructor argument. |
| new2 | Object new2(Object cls, Object arg1, Object arg2) |
Instantiates a class with two constructor arguments. |
| new3 | Object new3(Object cls, Object arg1, Object arg2, Object arg3) |
Instantiates a class with three constructor arguments. |
| number | Number number(Object value) |
Converts an object to a number. |
| parseDate | Date parseDate(String source, String pattern) |
Parses a string into a Date with the given pattern. |
| parseNumber | Number parseNumber(String source, String pattern) |
Parses a string into a number with the given pattern. |
| property | String property(String key) |
Returns the value of the given library property, or null. |
| render | void render(ActionContext ac) |
Renders a DSP fragment. |
| replace | String replace(String src, String from, String to) |
Replaces all occurrences of from in src with to. |
| split | String[] split(String value, String regex) |
Splits the string by the given regular expression. |
| startsWith | boolean startsWith(String value, String prefix) |
Tests whether the string starts with the prefix. |
| string | String toString(Object value) |
Converts an object to a string. |
| substring | String substring(String s, int from, int to) |
Returns a substring of the given string. |
| testCurrentLocale | boolean testCurrent(String lang, String country) |
Tests whether the current locale matches the language/country. |
| toLowerCase | String toLowerCase(String value) |
Converts the string to lowercase using the current locale. |
| toUpperCase | String toUpperCase(String value) |
Converts the string to uppercase using the current locale. |
| trim | String trim(String value) |
Returns the string with leading and trailing whitespace removed. |