Putting SPELs on ADF Code html

Putting SPELs on ADF Code

There is a simple way to use the Expression language you use in JSTL expressions in your JSP’s, in ADF’s DataAction. Actually anywhere you can get hold of a LifeCycleContext (or any subclass) you can use SPEL. What you need is the class oracle.adf.controller.lifecycle.Evaluator.
You can obtain one like this
.

Evaluator eval = Evaluator.getEvaluator(lifeCycleContext);

You can feed this baby EL expressions just like in a JSP. The following code snippets show examples of doing it the code way as opposed to doing it the EL way

Getting a request parameter


daContext.getHttpServletRequest().getParameter("name");
(String)eval.getValue("${param.name}")

Setting a Session Atribute


daContext.getHttpServletRequest().getSession().setAttribute("SORTMANAGERPROVIDER", prov);
eval.setValue("${sessionScope.SORTMANAGERPROVIDER}", prov);

Getting a ControlActionBinding


DCBindingContainer bc = daContext.getBindingContainer();
JUCtrlActionBinding action = (JUCtrlActionBinding) bc.findCtrlBinding("sortAny");
JUCtrlActionBinding action = ( JUCtrlActionBinding ) eval.getValue("${bindings.sortAny}");

There must be some overhead involved in the ExpressionEvaluator. In my simple method I didn’t measure any significant differences in performance.
But be sure to SPELL your expressions right to avoid runtime errors ..

3 Comments

  1. hans December 7, 2004
  2. Leon van Tegelen December 4, 2004
  3. hans December 3, 2004