JSF Expression Language and Value Binding Explained
How Faces expressions read and write bean properties, when immediate and deferred evaluation matter, and the operators and implicit objects you will use.

Expression Language (EL) is the glue between a Faces page and its beans. It is small, and most problems with it come from three misunderstandings: when it is evaluated, which direction a value binding works, and what a path does with a null. This post covers the parts you will use. It supports the JSF tutorial and the map in JSF and PrimeFaces for maintainers.
Deferred evaluation
Faces expressions use #{...}. They are deferred: the framework evaluates them at the moment it needs the value, which can be several times for one page request. The ${...} form of JSP evaluates immediately, once. In Facelets, use #{...}.
<h:outputText value="#{order.total}" />
<h:inputText value="#{order.customerName}" />
<h:commandButton action="#{orderBean.save}" />Value expressions are two-way
For an output component, #{order.total} reads the property: EL calls getTotal(). For an input component, the same kind of expression is used twice: on render it calls the getter to show the value, and on submit, during the update model phase, it calls the setter with the converted value. That is why an input bound to a read-only property (no setter) fails on submit with PropertyNotWritableException. The phase in which the setter runs is covered in the JSF lifecycle.
Paths and nulls
#{orderBean.order.customer.name} is resolved from left to right: the bean orderBean, its property order, that object's customer, then name. If any segment before the last is null during a read, EL for output returns an empty string, and for an input write it throws [Target Unreachable](/library/target-unreachable-identifier-resolved-null-fix). Initialize the objects in the path.
Collections and maps use brackets:
#{orders[0].total}
#{prices['gold']}
#{customer.addresses[index].city}Method expressions
An action is a method expression. Without parentheses, Faces calls a no-argument method:
<h:commandButton value="Save" action="#{orderBean.save}" />Jakarta EL lets you pass arguments, which is convenient inside a table row:
<p:dataTable value="#{orderBean.orders}" var="o">
<p:column>
<p:commandButton value="Cancel" action="#{orderBean.cancel(o)}" />
</p:column>
</p:dataTable>The method cancel(Order order) receives the row object. An action method may return a String navigation outcome or void.
Operators and conditions
EL has the usual operators and some word forms: eq, ne, lt, gt, and, or, not, empty, and the ternary ? :.
<h:outputText value="Paid" rendered="#{order.status eq 'PAID'}" />
<h:outputText value="#{empty order.notes ? 'No notes' : order.notes}" />empty is true for null, an empty string, an empty collection or an empty array. Inside an XML attribute use eq, lt, gt instead of < and > to avoid escaping.
Implicit objects
| Object | Contains |
|---|---|
param | Request parameters, as a map |
request | The HttpServletRequest |
session | The session |
facesContext | The FacesContext |
component | The current component |
view | The current UIViewRoot |
<h:outputLink value="#{request.contextPath}/orders.xhtml">Orders</h:outputLink>
<h:outputText value="#{param.id}" />Keep logic in the bean
A getter called from EL may run many times per request (rendering, rendered conditions, ajax). Do not do work in a getter: no database access, no loops over large lists. Load data once into a field, in @PostConstruct or a <f:viewAction>, and let the getter return it.
@PostConstruct
void init() { orders = repository.findOpenOrders(); }
public List<Order> getOrders() { return orders; }Loop variables and when they exist
Two loop tags look alike and evaluate at different times, which causes a well-known puzzle. c:forEach runs while the view is built, and ui:repeat runs while it is rendered:
<!-- build time: the collection must be ready when the view is built -->
<c:forEach items="#{orderBean.lines}" var="line">
<h:outputText value="#{line.name}" />
</c:forEach>
<!-- render time: the collection is read during each render -->
<ui:repeat value="#{orderBean.lines}" var="line">
<h:outputText value="#{line.name}" />
</ui:repeat>A view-scoped bean that loads its list in a method called on a button click has no data yet when the view is built, so the c:forEach shows nothing, while the ui:repeat shows the list after the action runs. Use ui:repeat and h:dataTable for anything that changes during the life of the view. The same split affects c:if against the rendered attribute: c:if is decided once at build time, and rendered is evaluated each time the component is rendered or processed.
Rendered conditions run in several phases
A rendered expression is evaluated in the render phase and also during the apply and validate phases on a postback, to decide whether a component takes part. If it depends on a value that changes between those phases, the component disappears from processing:
<h:inputText value="#{form.nickname}" rendered="#{form.showNickname}" />When the checkbox that controls showNickname is part of the same submit, the order of updates matters: the value reaches the bean after validation, so on that postback rendered is still false at the earlier phases, and the input is skipped. Put the flag in a view-scoped bean, set by an AJAX request first, and the following postback sees a stable value. A lost field value in a conditional form is the usual symptom.
What the common errors say
| Message | Cause |
|---|---|
PropertyNotFoundException: Property 'nmae' not found on type ... | A typo, or no getter with that name |
MethodNotFoundException: Method not found: ...save() | The method name or its parameter count is wrong |
Target Unreachable, identifier 'orderBean' resolved to null | The bean is not registered, or is not in the scope searched |
Target Unreachable, 'null' returned null | A step in the path was null, so the next step cannot be reached |
ELException: Cannot convert ... to type ... | The value cannot be coerced to the property type |
The fourth message names null as the identifier, which confuses readers. It means that a segment of the path was null, for example order.customer.name with no customer, when the expression is used as a value binding target on a postback. Reading the same path on render returns an empty string, and writing through it fails.
Parameters in method expressions
Since EL 2.2 a method expression may pass arguments, which removes the need for many helper properties:
<h:commandButton value="Delete" action="#{orderBean.delete(order.id)}" />
<h:commandLink value="Open" action="#{navigator.open('orders', order.id)}" />The arguments are evaluated when the button is pressed, in the invoke application phase. For a row in a table, the row object is available through the iteration variable, so the method receives the right row without a selected-row property. Literals are quoted with single quotes inside the double-quoted attribute.
Where to keep logic
An expression like #{order.total gt 1000 and order.customer.vip ? 'gold' : 'plain'} is correct and untestable. Move it to a method on the bean and test it in plain Java:
public String badgeFor(Order order) {
return order.total().compareTo(THRESHOLD) > 0 && order.customer().vip() ? "gold" : "plain";
}<h:outputText value="#{orderBean.badgeFor(order)}" />The expression now holds a call, and the rule is a method with a unit test. As a rule of thumb, any expression with more than one operator belongs in the bean.
Where this does not apply
PrimeFaces and other libraries add EL functions, and a custom ELResolver can add new roots such as Spring beans. If an expression fails to compile, the cause is often an EL version mismatch between the application and the server. The Jakarta Expression Language specification and the Faces documentation of the Jakarta EE tutorial are the primary sources.


