24.3. Evaluating EL Expressions
Seam Remoting also supports EL expression evaluation, which is another convenient method of retrieving data from the server. The
Seam.Remoting.eval()
function lets the EL expression be remotely evaluated on the server, and returns the resulting value to a client-side callback method. This function accepts two parameters: the EL expression to evaluate, and the callback method to invoke with the expression value. For example:
function customersCallback(customers) { for (var i = 0; i < customers.length; i++) { alert("Got customer: " + customers[i].getName()); } } Seam.Remoting.eval("#{customers}", customersCallback);
Here, Seam evaluates the
#{customers}
expression, and the value of the expression (in this case, a list of Customer
objects) is returned to the customersCallback()
method. Remember, objects returned this way must have their types imported with s:remote
for you to work with them in JavaScript. To work with a list of customer
objects, you must be able to import the customer
type:
<s:remote include="customer"/>