How to reference constants in EL?

EL 3.0 or newer If you’re already on Java EE 7 / EL 3.0, then the @page import will also import class constants in EL scope. <%@ page import=”com.example.YourConstants” %> This will under the covers be imported via ImportHandler#importClass() and be available as ${YourConstants.FOO}. Note that all java.lang.* classes are already implicitly imported and available … Read more

javax.el.PropertyNotFoundException: Property ‘foo’ not found on type com.example.Bean

javax.el.PropertyNotFoundException: Property ‘foo’ not found on type com.example.Bean This literally means that the mentioned class com.example.Bean doesn’t have a public (non-static!) getter method for the mentioned property foo. Note that the field itself is irrelevant here! The public getter method name must start with get, followed by the property name which is capitalized at only … Read more

JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output

There are three main causes. FacesServlet is not invoked. XML namespace URIs are missing or wrong. Multiple JSF implemenations have been loaded. 1. Make sure that URL matches FacesServlet mapping The URL of the link (the URL as you see in browser’s address bar) has to match the <url-pattern> of the FacesServlet as definied in … Read more

Why JSF calls getters multiple times

This is caused by the nature of deferred expressions #{} (note that “legacy” standard expressions ${} behave exactly the same when Facelets is used instead of JSP). The deferred expression is not immediately evaluated, but created as a ValueExpression object and the getter method behind the expression is executed everytime when the code calls ValueExpression#getValue(). … Read more

Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable

1. Target Unreachable, identifier ‘bean’ resolved to null This boils down to that the managed bean instance itself could not be found by exactly that identifier (managed bean name) in EL like so #{bean}. Identifying the cause can be broken down into three steps: a. Who’s managing the bean? b. What’s the (default) managed bean … Read more