Tuesday, November 2, 2010

Expression Language Conversion in ADF

Expression Language (EL) is widely used in ADF Binding to reference items in the Binding Context. In some scenario, direct use of EL reference isn't enough and manipulation of several EL references needed to accomplish the task. While you can always manipulate the logics in a manged bean, if you want to go with "declarative", here is why I am saying about.

Varchar2 type in SQL format (database) is converted to String automatically, but Number type in SQL is converted to oracle.jbo.domain.Number format. EL inherit generic Java API and can only recognize java.lang.Number type.

Therefore, if you have two EL binding references to two database Number attributes: #{bindings.NumberAtt1.inputValue} and {bindings.NumberAtt2.inputValue}. If you want to evaluate if the first number greater than the second number, you cannot use compareTo() method which is belongs to oracle.jbo.domain.Number and you cannot use #{A > B} because A or B is not java.lang.Number

A simple conversion is to attach ".value" in the end of EL binding reference and it will convert it to a java.lang.Double format type.


Anonymous said...

how abt string type, can you give me some example of the string.

for ex:

actually i have "Y" returned by above binding when i try to use like
"#{binding.myAttr.inputValue=='Y'?'true':'false'}, its not comparing the value.

please suggest me,

JayJay Zheng said...


if it's Varchar2 type in DB and it's automatically converted to String in EL. You can print out the value of #{bindings.myAttr.inputValue} first to see whether it returns "Y".

Anonymous said...

When I print that value using outputtext it displays correctly Y, but when i put in EL no action.

currently i am handling with hidden(invisible) outputtext which has the binding in bean, then i am using with this binding var, in another method which is avbl in same bean, it consumes server calls, hence performance issue raises.

suggest me right way how to handle this using #{binding.xx.inputValue}

Anonymous said...

One point here is, I am using this inside the iterator. And it seems that coming as Object instead of wrapper(String, Integer, etc.,)

Let me know if there is any other way we can handle this without calling to Bean.


JayJay Zheng said...

Hey anonymous reader,

If you need my help, please explain the use case and any codes you are implementing. It's hard to guess what you are doing.

DRS said...

i have a number in EL(DB field is number) i.e.
how to convert this into String???

JayJay Zheng said...


You'd better do it in the managed bean to convert the Number to String type and reference it from the EL.

Anonymous said...


When we use IN clause in the query used to create View object,
how do we give multiple parameter values?

Progaming said...

Thanks for the useful Information........,

Bigo Live Stream users