What exactly is #{component} in EL?

The #{component} is an implicit EL variable referring the current UIComponent in EL scope (see also implicit EL objects). You can usually only refer it in component’s HTML attribute or in template text children. E.g. in case of <h:inputText> it will reference an instance of UIInput class which has among others an isValid() method. <h:inputText … Read more

Differences between EL 2.1 and 2.2

The answer is in the EL 2.2. specification document. Here’s an extract of relevance: A.1 Changes between Maintenance 1 and Maintenance Release 2 The main change in this release is the addition of method invokations with parameters in the EL, such as #{trader.buy(“JAVA”)}. Added one method in javax.el.ELResolver: Object invoke(ELContext context, Object base, Object method, … Read more

How to use EL in PrimeFaces oncomplete attribute which is updated during action method

PrimeFaces doesn’t support it. Any EL expressions in oncomplete attribute are immediately evaluated during render response of that HTML document, not during oncomplete of the associated ajax call. Basically, the JavaScript code generated by oncomplete attribute contains the old value as it was during the page load. Your best bet is using RequestContext#addCallbackParam() to add … Read more

javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL does not work anymore since Java EE 7 / EL 3.0

Fixed with a custom resolver: faces-config.xml: <application> <el-resolver>my.package.EmptyNullStringResolver</el-resolver> </application> EmptyNullStringResolver.java: /** * @author pg */ public class EmptyNullStringResolver extends ELResolver { @Override public Class<?> getCommonPropertyType(ELContext context, Object base) { return String.class; } @Override public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } @Override public Class<?> getType(ELContext context, Object base, Object property) { return null; … Read more

How to set -Dorg.apache.el.parser.COERCE_TO_ZERO=false programmatically

You can set the system properties programmatically using System#setProperty(). System.setProperty(“org.apache.el.parser.COERCE_TO_ZERO”, “false”); However, you need to ensure that this is been set before JSF/EL ever get initialized. Best place would be a ServletContextListener. public class Config implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { System.setProperty(“org.apache.el.parser.COERCE_TO_ZERO”, “false”); } @Override public void contextDestroyed(ServletContextEvent event) { // NOOP … Read more

Use EL ${XY} directly in scriptlet

You’re mixing scriptlets and EL and expecting that they run “in sync”. That just won’t work. The one is an oldschool way of writing JSPs and the other is a modern way of writing JSPs. You should use the one or the other, not both. Coming back to the concrete question, under the hoods, EL … Read more

Invoke method with varargs in EL throws java.lang.IllegalArgumentException: wrong number of arguments

No, it is not possible to use variable arguments in EL method expressions, let alone EL functions. Your best bet is to create multiple different named methods with a different amount of fixed arguments. public static boolean isValueIn2(Integer value, Integer option1, Integer option2) {} public static boolean isValueIn3(Integer value, Integer option1, Integer option2, Integer option3) … Read more