Another powerful feature of Facelets is the possibility to create static functions. Static functions let you expand the possibilities of the JSF Expression Language. You can, in fact, configure any static Java function that is on the classpath to be available as a static function in the Expression Language. This is fairly simple to do.
Let's assume that the CEO of Monsters, Inc—Mr. Waternoose—wants to add an inspirational quote of the day to the login page of the MIAS system. Let’s see how we can implement this by using the Facelets static function feature. First, we need a static method that returns a quote. As we want to display the author of the quote as well, let’s create two functions, as follows:
package inc.monsters.mias;
public class FaceletsFunctions {
private static Quote lastQuote;
private static Quotes quotesList;
private static Quotes getQuotes() {
if (quotesList == null) {
// fill the quotes list from a file or something
}
return quotesList;
}
public static...