In the last week I had several issues during the development of a jsf application that could be solved by creating few custom Facelets EL functions, let’s take a look on which scenarios Facelets EL functions helped me.
1. Simple loop over a range of numbers
JSF has a lot of components that can be used to iterate over a model and repeat its own child components several times, some of them are Tomahawk’s dataList and Richfaces repeat.
But in all of these components I couldn’t find a way to do a simple iteration on a range of numbers, like repeat all child components starting from 1 and stopping at n number of times.
Maybe you will say: “What about c:forEach? It can do this kind of iteration!”, oh yes, it can, and I tried to use it but it crashes when I pass EL expressions to both begin and end attributes, it only accepts hardcoded values.