Write Java Code in View Layer (cont.)

Complete Oracle ADF 12c Course for Beginners Write Java Code in Model and View Layer
24 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
€67.24
List Price:  €96.07
You save:  €28.82
£55.68
List Price:  £79.55
You save:  £23.86
CA$100.66
List Price:  CA$143.82
You save:  CA$43.15
A$111.82
List Price:  A$159.75
You save:  A$47.93
S$94.88
List Price:  S$135.55
You save:  S$40.66
HK$543.79
List Price:  HK$776.87
You save:  HK$233.08
CHF 62.67
List Price:  CHF 89.54
You save:  CHF 26.86
NOK kr792.28
List Price:  NOK kr1,131.89
You save:  NOK kr339.60
DKK kr501.55
List Price:  DKK kr716.53
You save:  DKK kr214.98
NZ$123.71
List Price:  NZ$176.74
You save:  NZ$53.02
د.إ257.07
List Price:  د.إ367.25
You save:  د.إ110.18
৳8,328.16
List Price:  ৳11,897.89
You save:  ৳3,569.72
₹5,958.01
List Price:  ₹8,511.81
You save:  ₹2,553.80
RM314.25
List Price:  RM448.95
You save:  RM134.70
₦108,236.03
List Price:  ₦154,629.53
You save:  ₦46,393.50
₨19,398.69
List Price:  ₨27,713.60
You save:  ₨8,314.91
฿2,394.21
List Price:  ฿3,420.45
You save:  ฿1,026.24
₺2,465.01
List Price:  ₺3,521.60
You save:  ₺1,056.58
B$426.13
List Price:  B$608.79
You save:  B$182.65
R1,290
List Price:  R1,842.93
You save:  R552.93
Лв131.30
List Price:  Лв187.58
You save:  Лв56.28
₩101,582.03
List Price:  ₩145,123.41
You save:  ₩43,541.37
₪254.54
List Price:  ₪363.65
You save:  ₪109.10
₱4,098.92
List Price:  ₱5,855.86
You save:  ₱1,756.93
¥10,967.38
List Price:  ¥15,668.35
You save:  ¥4,700.97
MX$1,406.50
List Price:  MX$2,009.38
You save:  MX$602.87
QR254.06
List Price:  QR362.96
You save:  QR108.89
P963.25
List Price:  P1,376.14
You save:  P412.88
KSh9,053.20
List Price:  KSh12,933.70
You save:  KSh3,880.50
E£3,568.78
List Price:  E£5,098.48
You save:  E£1,529.69
ብር8,687.63
List Price:  ብር12,411.43
You save:  ብር3,723.80
Kz64,250.82
List Price:  Kz91,790.82
You save:  Kz27,540
CLP$69,297.02
List Price:  CLP$99,000
You save:  CLP$29,702.97
CN¥510.87
List Price:  CN¥729.84
You save:  CN¥218.97
RD$4,243.89
List Price:  RD$6,062.96
You save:  RD$1,819.07
DA9,435.69
List Price:  DA13,480.14
You save:  DA4,044.44
FJ$162.05
List Price:  FJ$231.51
You save:  FJ$69.46
Q536.99
List Price:  Q767.16
You save:  Q230.17
GY$14,580.66
List Price:  GY$20,830.41
You save:  GY$6,249.74
ISK kr9,757.30
List Price:  ISK kr13,939.60
You save:  ISK kr4,182.30
DH701.41
List Price:  DH1,002.06
You save:  DH300.64
L1,291.33
List Price:  L1,844.84
You save:  L553.50
ден4,135.36
List Price:  ден5,907.91
You save:  ден1,772.55
MOP$557.92
List Price:  MOP$797.07
You save:  MOP$239.14
N$1,283.07
List Price:  N$1,833.03
You save:  N$549.96
C$2,564.57
List Price:  C$3,663.83
You save:  C$1,099.26
रु9,479.94
List Price:  रु13,543.35
You save:  रु4,063.41
S/259.51
List Price:  S/370.75
You save:  S/111.23
K282.61
List Price:  K403.75
You save:  K121.13
SAR262.99
List Price:  SAR375.71
You save:  SAR112.72
ZK1,928.73
List Price:  ZK2,755.44
You save:  ZK826.71
L334.62
List Price:  L478.06
You save:  L143.43
Kč1,690.23
List Price:  Kč2,414.72
You save:  Kč724.49
Ft27,882.67
List Price:  Ft39,834.10
You save:  Ft11,951.42
SEK kr772.23
List Price:  SEK kr1,103.23
You save:  SEK kr331
ARS$71,547.27
List Price:  ARS$102,214.77
You save:  ARS$30,667.50
Bs481.59
List Price:  Bs688.02
You save:  Bs206.42
COP$305,890.51
List Price:  COP$437,005.17
You save:  COP$131,114.66
₡35,162.35
List Price:  ₡50,234.08
You save:  ₡15,071.73
L1,769.11
List Price:  L2,527.41
You save:  L758.30
₲543,432.39
List Price:  ₲776,365.26
You save:  ₲232,932.87
$U3,131.93
List Price:  $U4,474.38
You save:  $U1,342.44
zł286.59
List Price:  zł409.44
You save:  zł122.84
Already have an account? Log In

Transcript

Hello. In this video I will continue talking about how you can write some custom code in the view layer. I will give here in this video some example like how you can get the view object which displays at that and change the wear clothes in Zara time is a bag been how you can get a traitor from each definition and to loop over all row and these information from zero how we can both value in decision scope and display this value in another page. So let us do all of this thing is in this video. Last video we create here in the department template we created Let's open it and see here here's the department the form which we created here I will add some few buttons Each button will do something in the back pain. So this is add in the form here.

One eight if button. Suddenly shirt site bottom. Okay, I can see here filter view object okay another proton reset Yoshi to get the old data again here no over traitor Your value in session school so let's try to implement code for all of this bottom okay? Save As you know here this table Oh because we make some change okay. So this table is read from a view object which has a weird clothes department view here this is a query which will return all departments you can change the workload was this query in the back been? In case no, you don't need all the department I need only a department which has ID equal 80 for example, you need to filter the data as a table data within some condition this is depending on your system requirement.

So I will show you how you can change this with clothes in the back being so here's the filter vo is action okay. So, these are action and action listener I will tell you what is different between both of them actionlistener will be fire before auction. So this is if you have two methods here. Section is or will fire first after that we'll go for Action. Action action is used if you want to navigate to another bitch. You make some navigation.

In case if you don't want to make any navigation you just want to make some changes that is a screen self. So You can use action listener. So this is use action listener here. I will say filter dipped vo okay action listener. This add another Mrs for all was also put on here. I will say we said it the vo just enough loop over dipped vo okay Actually to put a value in decision scope, there are two ways you can do it in the managed bean or using a expression language.

So let me add another button to show you how you can do this as well. Put value institutions cool. Sorry, what's video session scope from being good value session scope? Yeah. Okay. So this is from beam.

So let us add action listener, add value, and session, school. Okay. So let's go to the pin here. Here we need to filter the department view to change the where clause so what we can do first we need to get the view object in my bag we in here so I will right here view object the object dept vo equal one if you till I get a traitor here no okay this is you need to import Oracle to GVO that V object okay. So we can see my util dot get lightweight. So, first thing to get the view object of course you can get the object throws a traitor as you see from here the iterator will point to the view object it is actually not our which is or which will go to which definition you will find here that department a traitor which is pointing to the view object here so I need to get first iterator and the forms iterator I will pick the view object.

So, let us take a trait or name here so I will now get the iterator from the iterator I need to get the view object Do you right to get in view object. So now you have the department view object in your bag bean now, after that you need to change the where clause so you write the vo dot sorry veoh dot sit in we're close you right here so we're close. You want to work where what where you can open the department you can see him for example, department ID equals eight So here you will change the word coalos. After you change after you change the word close a few objects, you have to execute again the query execute query. So this is how you can filter the view object with a specific workload if you want to change the workload of values of the object.

So that you will filter the value here. This is dependent on your application business, sometimes you want to filter the data depending on some condition, so you can do it like this. Literally set it to return the back or rows again. So you will get the view object and you sit at work close equal to b. Now, you will clear the where clause and execute query again. Here's how you can loop over the three two rules and read this value.

So how you can do this You can write DC a traitor. Binding you get a traitor. The ITER equal don't get a trade. So the first thing is you get a trade which you won't we will look over it we will import ok alt Enter to import. So now we have a traitor in our back beam Let us now need to loop over this a traitor. So we write for i equals zero.

What if I listen don't get stimulated through count i plus plus. Then you say rule or equal it dipped, HR dot get Through a three inch index Oh, sorry. So, to look over in a traitor in your page, for example, if you want to check some any value, you want to just loop over it, you want to set some value if a department ID equals something, so let us see how it works. So first you get the iterator forums there, binding iterators from the binding the hydrator which you will loop over it. After that, you will write a for loop where info equals zero and it lists then iterator dot get estimated row count. And after that you will say forums iterator get row at range index.

So it will go row by row. We can't wait to div id we can write our dot get attribute of course you get attribute from the view object because this a traitor has the same attribute from the view object. So you can see department ID okay and you can print as well deep name r dot get attribute or is zero control of partment now, I just will print it and you can write any condition and since attribute for example, if our get attribute of department ID dot last two string to equal For the for example, I need to set if it is 90 cents the department name to or if it is 100 sister the words mean name finance 100 for example, once a person it so if the department equals 100 we need to set our city CIT attribute and department name to nice 100 this is just for that one example how it works.

So here little speck again and see I need to loop over the iterator or rose and do some business so I will get for its I traitor and I will move the traitor I will get row at range index i so I initially zero so zero means the first row once I get this 01 Go row by row. So, once I get zero, I have the department ID name manager location all now I have it. So, I would say I just need get attribute to work with name get attribute department ID and I can make some chick IF IT department ID equal whatever you can set another attribute. So, let us make this as an example. Okay, here in the last one is add value in the session scope. So here you can add some variable in the session, so that you can access this variable anywhere in your application in a beach.

Like once a user is logon, you need to save the user ID. So that you will use this user ID in in many way in many places in the application. So if you want to sit value in the session scope, it is easy you can there is a predefined methods we defined in my ad futile dot book instance. Scope here what is the key the key of the is a session scope name we can say for example, the name this is the name of the session scope. And I will see here my on the device dip. For example, I will store this value in the session scope was variable called the key name.

I will show you how you can store some value in decision scope and without using in back pain but in a way in the back mean we will need it in some situation like in the logon, but I will show you another way. So, here is also if you have if you want to press a button and set some value maybe from your I trait or from the binding or from an era Later. So, you can easily do it like you can bris here I need a faces you can insert inside this bottom sit action listener okay. So you can say I need from and to solve you can open the expression here okay. You can say for example, I need to need to maybe to the workmen report department name input value okay. This is a permit name symbol value are you to store it in that session scope you will find here GSP object session school dot Deep name for example, this is any name you want, but this is the value which will be stored on it, we can see it is the name.

Okay, so what will happen now I add an action listener to this button that says this button, it will take the value which is in the department name and put it in decision scope in the department the name okay it will be like this action is not inside this button, I think is a value here it is deep name as well. So, if I press this button, the deputy name value will be my own department name. But if I press this button, I will override the deputy name in the session scope with a department name. You can easily get it from here if you have a department name, you can take the value of the department name and put it here or any value in your binding or in in your form or in whatever in your page in it. In attributes in a component in your bit you can take the value of this component and put it here if you want to store its value in the session scope.

So now you should be able to filter the view object reset it look over put in session and what in the session by a different way let us display the values decision is also bitch. So we have now this variant decision it will display it somewhere in the employees also bitch does that you will see it is you can get the value so we can we have only here a table we can surround this table with by the group because we need to add more. Okay, and I will add here, our tickets I just will split our tickets. Okay, just a space here I can see it dip name from session okay and I should add here expression and I see a session school though my session variable name can edit into like this. So I just display it as an output ticket. Okay in the style you can make some stylization if you want to change the font choose family is a family font size, make it be x large and make it color maybe red to see it.

Read and do maybe weight bold. Okay, so just go make some change here to see the session variable. If you want to get this session from back been, you have another message to call don't get from session and he gives a key, which is the name if you want to get it from xebec bean to get the value from the session. So let's now try to run and test all this. So let's remember as the first one will filter the department to get only at the bottom it was id 80. So this is this is this filter so Let's now try to press in the filter view.

No. Oh, okay. I guess this is because of the Java in the Java Ember, we override this so we can we can should remove this room. Because once I explained the view object and Bill we add the condition. So in the back been if you call execute query, so it will execute this condition again which it will change the view object is why you should be object with clauses why it didn't make any effect. So, now let's try it again.

Okay, so here the department view you you will see it is gets all rows Okay, discloses or rows again. So, now let us go for department and I need to filter the view you will see now it is getting at which is in only one row because our workflows will return only one row so, it is one row if you reset, it will return the back again to all data again as you can see, okay, so now let's go for the loop you'll find 100 has delphinium finance here okay. So, we need to loop over the old and if it is 100 choose you to find this 100. So let us here see loop over the iterator. So, if you go here, you will see it is looped over the iterator and once it is 100 you find new optimum is one minus 100. So, this is how you can loop over the iterator and against the old value on the economic chick and some attribute.

So, if we back again here, you will find the dip name become five minutes 100 equals we said okay, so this is a reset, this is a loop both in the session scope. So, if you press in says, What happened now, in our code, we put zis value my own document in this session scope key. So, now, once I press on this, now, this key has this value. So this is navigate to the inventory and display this Deepti Name ki and see what it is. So, let us go to the MBE door yeah it is here. So, you find here Deepti name from session my own development because this value now inserted in this session.

So, let us back again and bring the other one from exhibition it exhibition language so, you will find here we bought change the value to be the department names the current department name which is public relations. So, if you back again and select the my department, you find it is public relations So, now you have some idea about how you can make some code related to filtering workloads receipting what we object how you can loop over to three to run to get some value from a trait on some attributes ID some attribute on some attribute how you can put value in decision scope by two ways how you can display it, hopefully, you will get some idea about how we can write some code in it if you layer by is this video I almost finished the whole view controller layer. So now we cover we covered the model and the view controller.

From next video, I will start we will start to develop a complete EDF application. So see you next video.

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.