Use Bind Variables in ADF Application Part 1

Advanced Oracle ADF 12c Course Model|Groovy Expression, Bind Variables and Overriding Methods
16 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.33
List Price:  €91.90
You save:  €27.57
£55.09
List Price:  £78.70
You save:  £23.61
CA$95.29
List Price:  CA$136.14
You save:  CA$40.84
A$104.44
List Price:  A$149.21
You save:  A$44.76
S$94.20
List Price:  S$134.58
You save:  S$40.38
HK$546.10
List Price:  HK$780.18
You save:  HK$234.07
CHF 63.62
List Price:  CHF 90.89
You save:  CHF 27.27
NOK kr751.73
List Price:  NOK kr1,073.95
You save:  NOK kr322.21
DKK kr480.45
List Price:  DKK kr686.39
You save:  DKK kr205.93
NZ$114.09
List Price:  NZ$162.99
You save:  NZ$48.90
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,195.22
List Price:  ৳11,707.96
You save:  ৳3,512.74
₹5,830.20
List Price:  ₹8,329.22
You save:  ₹2,499.01
RM328.07
List Price:  RM468.70
You save:  RM140.62
₦102,885.30
List Price:  ₦146,985.30
You save:  ₦44,100
₨19,393.48
List Price:  ₨27,706.17
You save:  ₨8,312.68
฿2,536.99
List Price:  ฿3,624.43
You save:  ฿1,087.43
₺2,256.71
List Price:  ₺3,224.01
You save:  ₺967.30
B$357.27
List Price:  B$510.40
You save:  B$153.13
R1,265.02
List Price:  R1,807.25
You save:  R542.23
Лв125.89
List Price:  Лв179.86
You save:  Лв53.96
₩94,793.75
List Price:  ₩135,425.45
You save:  ₩40,631.70
₪259.28
List Price:  ₪370.41
You save:  ₪111.13
₱4,039.50
List Price:  ₱5,770.97
You save:  ₱1,731.46
¥10,895.69
List Price:  ¥15,565.94
You save:  ¥4,670.25
MX$1,162.43
List Price:  MX$1,660.69
You save:  MX$498.25
QR253.91
List Price:  QR362.75
You save:  QR108.83
P948.27
List Price:  P1,354.73
You save:  P406.46
KSh9,168.69
List Price:  KSh13,098.69
You save:  KSh3,930
E£3,283.23
List Price:  E£4,690.53
You save:  E£1,407.30
ብር4,009.02
List Price:  ብር5,727.42
You save:  ብር1,718.40
Kz59,310.71
List Price:  Kz84,733.22
You save:  Kz25,422.51
CLP$62,605.89
List Price:  CLP$89,440.82
You save:  CLP$26,834.93
CN¥505.55
List Price:  CN¥722.24
You save:  CN¥216.69
RD$4,078.44
List Price:  RD$5,826.59
You save:  RD$1,748.15
DA9,404.82
List Price:  DA13,436.03
You save:  DA4,031.21
FJ$155.95
List Price:  FJ$222.79
You save:  FJ$66.84
Q543.74
List Price:  Q776.81
You save:  Q233.06
GY$14,641.89
List Price:  GY$20,917.88
You save:  GY$6,275.99
ISK kr9,678.91
List Price:  ISK kr13,827.61
You save:  ISK kr4,148.70
DH693.20
List Price:  DH990.33
You save:  DH297.13
L1,231.95
List Price:  L1,760
You save:  L528.05
ден3,957.99
List Price:  ден5,654.52
You save:  ден1,696.52
MOP$562.43
List Price:  MOP$803.51
You save:  MOP$241.07
N$1,273.79
List Price:  N$1,819.78
You save:  N$545.99
C$2,572.13
List Price:  C$3,674.63
You save:  C$1,102.50
रु9,330.17
List Price:  रु13,329.38
You save:  रु3,999.21
S/260
List Price:  S/371.45
You save:  S/111.44
K271.59
List Price:  K388.01
You save:  K116.41
SAR262.46
List Price:  SAR374.96
You save:  SAR112.50
ZK1,777.13
List Price:  ZK2,538.86
You save:  ZK761.73
L320.28
List Price:  L457.57
You save:  L137.28
Kč1,590.03
List Price:  Kč2,271.57
You save:  Kč681.54
Ft24,925.85
List Price:  Ft35,609.88
You save:  Ft10,684.03
SEK kr750.08
List Price:  SEK kr1,071.59
You save:  SEK kr321.50
ARS$62,063.63
List Price:  ARS$88,666.13
You save:  ARS$26,602.50
Bs483.56
List Price:  Bs690.83
You save:  Bs207.27
COP$266,463.69
List Price:  COP$380,678.73
You save:  COP$114,215.04
₡35,817.30
List Price:  ₡51,169.76
You save:  ₡15,352.46
L1,723.87
List Price:  L2,462.78
You save:  L738.91
₲524,369.02
List Price:  ₲749,130.70
You save:  ₲224,761.68
$U2,697.33
List Price:  $U3,853.49
You save:  $U1,156.16
zł274.39
List Price:  zł392.01
You save:  zł117.61
Already have an account? Log In

Transcript

Hello, in this video I will talk about bind variables and I will show you how you can sit and create this point variables I created a publication. So, now let us try to set some bind variables in the view and see how it will work for example, in the in believe you I need to set point I need to create point variable in the main query as I said in previous video point variable can be created in the main query or in the view criteria. So, let's start with the main query. Okay, so I need to create a view object and in this view object I need to set the department ID and I will need to get the employee for from this department ID. So I will right here we are where the movie department ID equal to defined by new variable race this column and write that bind variable name like the ID okay.

So, sorry, this is here it will ask you if you want to create bind variable for this of type, what what type if you want would you want okay it's string okay. So it will create here, a bind variable for this mean view object. This department ID for example, we need been the ones that login user wants as a user logged into the system. I will check what is the department ID sis user belongs to. And I need the employee view object to be always filtered depending on the user department. In that case, I need the mean in believe you object to the filter Start by department ID.

So in the mean we're close, I said where department ID equal column and the binding variable name. And here in the bind variables, we defined the same name, which we use it here of type string. Okay, that's fine. So, how we can set this point variables, as I said, there are multiple ways we can you can do this, I will show you two ways now, which is most commonly ways we can use. First first method is, first way is to use groovy expression which will point to method in the Java class. Here, once you select the department, this also is a bind variable, you can add a literal value literal value, like this would be fixed like 10.

Okay, but we don't want to either fix it very, very value. We need to be dynamic Sometimes user will send it. So, how we can do this first we need to create plus in the model layer and in this class, I should write a method, this method will return the department ID. And from here in this exhibition I will point to this method. So, let us now try to create a class. So, in your mean mode in your model you should create a Java class for example, I will call it model util okay and we can add a package called common for example, and okay so, now I am explain the way in which you can set a bind variable using groovy expression boy in two minutes method in a Java class.

So, now I create a Java class. And I need to write a method here, which returns a department ID. So this message should be public static method. So it will return a string because the bind variable department ID which we defined here is a type of string. So I need the method to return string value. And we can write get user dept, or ID.

This is like my method name. Okay, here, I need to get the department ID from the logged in user. So usually you will get it from the session scope, for example, so we can get it from session scope like it if we can import it. Okay. Don't get current Good session scope to get and write that session score key. So we can say, in user depth.

And we should because as string here we can write return. So this this method, actually, it will connect to the session scope. And we'll get the value of the key called user depth. So in the login, we should set this variable in the session scope with the user department ID. Okay, now I need this bind very bind to this method, how we can do this actually you should get it from the package dot class dot get in function name or method name. So, it should be something like this model just put it here dot more than you two don't get it dipped ID.

So, this is separation, which we will write it in supine variable to go into this method in this class. So, I will take it and go to here in the expression function, I will add it like this. This is one way so that you can sit somewhere bind variable from a missile in a Java class and of course here you can do an All you want you can connect to the database is using SQL you can get any view object you have and think is a very useful for it and you get the value. So, you can write your own business here to get the department ID and this department will be set the bind variable, but for now I need to get a valid value from the session scope because this is most commonly situation we always do as the ADF application. Okay, is it still one thing is missing okay.

So let us try now to run and see if we let's let's first try to create a bitch and this this way, we can call it user Emily's All we can create a login page. So lettuce here carry two pages user and Bill m UI and just assemble assemble the page, which will set a value in the session scope. Here for example, login and I will create a login if okay and you just need to go ahead Okay, so just two simple pitch is the login I just want to add a department ID as if the I will get it from the login user. But for now I just will add the in with test with one button and you can sit the session scope with a value which is a user will enter and we'll check so here I will add a button login and once a user receives this login, I need to set value in the session scope and navigate to the user in bV.

Okay, but I need as well to add empty guests and you also should in terms of department ID User It's okay. Enzo user, Louis, I just will drag him believe you. If you didn't sit the bind variable, the view will return Normal Table Table. Okay. Okay, so now, this is the table here I just want to create action So I would create been and I would create login action cancel it, it's a double check here action should be like this Okay. So now we need to get the value from this and put it in the session scopes then going to this user ID actually we can do it without any code but I most of the things which I will do during this course to to show you how you can do everything programmatic.

So here I will go for buying think and I will add a component called user and bought tickets. Okay, so let's go to the pin here and we will get the IP ID equal in user dipped in tickets to get a value and from here we should put this value into the session scope thickest okay so we will import this Just faked tickets okay. His trophies will take us to get current nice 10 get an external take his session map put I will put system ID to what is the variable name or session variable name we will use the same what we use it here. So, I will put this department ID onto this session scope variable and in the model return model util I will return the value from this variable. Okay after that I will need to To return the M to go to the other pitch of course, this m is a outcome here it should be.

So, should be here like this, okay. So let's now try to run and see if there is any problem or not runs a login. Yes, see this is what I am. I need to tell you about it. You will find this error when you try to bind bind variables To the missile in the back beam. So, to solve this out you go to the bind variable here you find trans expression is a property you will find here trust mode, you can right here trust it, okay.

So let's run again okay. So this is drawn. So now we let us enter the user department for example, let us enter 20 and login you will find here the employee is filtered by 20. So, let us try to enter any other department and see, for example, it was in 30 years and 30 Logan it will get St. Louis from 30. So this is one way that you can sit is a bind variable from method in Java class using groovy expression you can point to this method. But as I told you to do this in the bind variable it says you should trust more to be trusted.

Otherwise you will get an exception. This is one way of doing that. Next video I will show you another way to sit so bind variable. So see you in activity

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.