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
<code>
daContext.getHttpServletRequest().getParameter("name");
(String)eval.getValue("${param.name}")
</code>
Setting a Session Atribute
<code>
daContext.getHttpServletRequest().getSession().setAttribute("SORTMANAGERPROVIDER", prov);
eval.setValue("${sessionScope.SORTMANAGERPROVIDER}", prov);
</code>
Getting a ControlActionBinding
<code>
DCBindingContainer bc = daContext.getBindingContainer();
JUCtrlActionBinding action = (JUCtrlActionBinding) bc.findCtrlBinding("sortAny");
JUCtrlActionBinding action = ( JUCtrlActionBinding ) eval.getValue("${bindings.sortAny}");
</code>
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 ..
Hey Leon,
you’re right, I got JSTL and EL mixed up. There’s only so much new technology I can take
Still I’m not too fond of using EL in code; and looking back, I see you’re mentioning the point yourself:
‘But be sure to SPELL your expressions right to avoid runtime errors’. Making a typo in a getter would of course
get you a compile-time error…