concept el in category seam

This is an excerpt from Manning's book Seam in Action.
The EL is an open API that allows custom resolvers to be registered, thus turning the EL into a variable hub. Consequently, any layer of the code that wants to tap into the EL unified variable context can do so using the public API. Thus, the EL frees you from having to develop a custom bridge between the variable contexts used by the different technologies in your application. Although you’re used to seeing the EL only in the view, there isn’t anything web specific about it.
Seam takes advantage of the EL in two ways. First, it registers a custom EL resolver that is aware of the Seam container. This allows Seam components to be accessed using EL notation from anywhere in the application where the EL is available (which is pretty much everywhere). Second, Seam makes heavy use of the EL under the covers, allowing EL notation to be used in annotations, configuration descriptors, log and message strings, Java Persistence Query Language (JPQL) queries, page flow definitions, and even business processes. With Seam, the EL truly is unified.
Listing 4.8. Using the Seam API and the EL in an integration test
package org.open18.action; import ...; public class RegisterActionIntegrationTest extends SeamTest { @Test public void registerValidGolfer() throws Exception { new FacesRequest("/register.xhtml") { @Override protected void updateModelValues() { Golfer g = (Golfer) Component.getInstance("newGolfer"); g.setFirstName("Tommy"); g.setLastName("Twoputt"); g.setUsername("twoputt"); g.setEmailAddress("twoputt@open18.org"); setValue("#{passwordBean.password}","ilovegolf"); setValue("#{passwordBean.confirm}","ilovegolf"); } @Override protected void invokeApplication() { String result = invokeMethod("#{registerAction.register}"); assert result != null && result.equals("success"); } }.run(); } }
Although simplicity remains the underlying theme in the final part of this book, the key word in this chapter is transparency. The investment you have made in learning about the JSF life cycle, Seam components, and the EL throughout this book pays off and helps you get your application rich quick. We begin by looking at how Ajax is transparently weaved into the JSF component model and the types of interactions this enables.
JavaScript remoting can tap into the Seam container via EL, whether it is to access values (value expressions) or execute methods (method expressions). You use the Seam.Remoting.eval() function to execute an EL expression, giving you a way to perform a remote operation without a @WebRemote method. Keep in mind that the resolved value is sent to a callback function asynchronously.