Converting ADF Number to Integer using EL

I spent about 20 minutes looking for this solution today - so I figured I'll just post this entry as a future reminder for myself...

I was using a Web Service data control that has an Integer parameter, and I wanted to get the value of EmployeeId from an ADF BC based ADF Faces table into it using an af:setProperty tag, but I got an error because the engine couldn't convert the jbo Number type to the needed Integer type.

Something like:

Cannot convert 203 of type class oracle.jbo.domain.Number to class java.lang.Integer
Turns out the solution is quite simple, add a .value to the end of the Number field EL.

So instead of 

                  <af:setPropertyListener from="#{row.EmployeeId}"
                                          to="#{bindings.EmployeeId.inputValue}"
                                          type="action"/>

use something like:

                  <af:setPropertyListener from="#{row.EmployeeId.value}"
                                          to="#{bindings.EmployeeId.inputValue}"
                                          type="action"/>

And the conversion just works.

Special thanks to this blog entry for the tip.


Comments:

Hi,
In my EO key is of type oracle.jbo.domain.Number
I am trying to use a setkey(myint) in a dodml().
myint is an integer value. it errors out saying oracle.jbo.domain.Number cannot set with java.lang.Integer.

Help please?

Posted by guest on September 11, 2011 at 07:59 AM PDT #

guest - hard to say without looking at your code and types - but maybe you need to convert your integer to Number - the Number type has constructor for this see the javadoc:
http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e10655/oracle/jbo/domain/Number.html

Posted by Shay on September 12, 2011 at 06:45 AM PDT #

Hi Shay,

How can we convert
java.lang.Integer/Long to oracle.jbo.domain.Number using EL.

Regards
Gayaz

Posted by guest on December 19, 2013 at 02:01 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today