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.