Since using EL expressions is a very handy feature for all kinds of purposes, they are supported by Calyxo in many places. As described in the Functions Reference section, Calyxo comes with three groups of predefined functions: Standard Functions (for string manipulation), Module Functions and Type Functions (for type conversions).
To be able to use additional functions in your EL expressions, you usually have to perform to steps:
- Write a public Java class containing a public static method for every function you intend to use. The only restriction one has to obey is, that no multiple method names are used. That means that instead of implementing two methods long max(long, long) and double max(double, double) you have to choose different method names like maxLong and maxDouble, or similarly long min(long, long) and long min(long, long, long) might be renamed to long min2(long, long) and long min3(long, long, long).
- Register your Java class in that configuration file, where it shall be used (registered functions are not imported!). This is done by using the <functions> tag as described in the Functions Reference section.
Of course, the first step may be skipped if a suitable Java class does already exist, either written by yourself or taken from a third party library. In other cases, a class providing all required functions does exist, but is not suitable as a functions class because of multiple method names (examples are the classes java.lang.Math, java.util.Arrays and java.util.Collections, which supply a lot of useful methods for number and collection manipulations). Here it is sufficient to write a new class which delegates all functionality to the desired class.