Hello, in this video I will talk about how you can refresh a page periodically like every second or every five seconds you make Do you want to refresh the data automatically. So, we can call it like a real data, real time data refresh. In this video, I will explain how you can do how I will show you how you can do this. For example, let us create a beach which has a time running time like 01234 and I need to get a number of employees a database and I will try to insert one in baleen. So that the big reveal and we will see that this number is will be refreshed inside the database. So let us first create a page.
I will call this page is refresh. This is just an empty fabrication I have created so now I will create one bitch We can add here when in group do it inside betting group do it I will add our tickets and after our test I went under our test does s3 open text just been improved oh it would have been the I need to be vertical and this sir Sarah window is battling through the horizont okay so this is we will be like a time and second and minutes which is running automatically and this is will be a number of number of employees in the database okay so we can add services as well was when a group do it and to add a title to it horizontal and we can add here before this idea as a no particular number of reuse shirt in weird ways.
So I will just display the number of him Bluey spacer and this would be the number of employee I can add a color, different color maybe discolor okay and Same here, this is a time running time it's an optic just between them and this optics will be just so cool. And I will add here and he is different color. The spacer between this and spacer between this and the meek because this horizontal makes all the width BMP five and we can add space between poses. Okay, so now I have a group node vertical so it will display both component under each other and the vertical way, the second, the first component would be horizontal so it will display our tickets. Since this column decided after that our tickets, this would be the minutes and seconds and this will be the minutes after that I will need to display number of registered employees and the interspeech account of this employee from the database and I need to of course is that to be refreshed automatically every one seconds of time should be changed automatically this time and as number from when we if I add one in between the database just in between should be changed automatically.
So let us implement this. So I will go through our checklist here. can use a value I would keep the value here I will keep the value and I will add pointing to a bit back pain. So I will add here pointing it I would kill it you by being my bean muy bien. View And I need to make the scoop here to be session because all he needs to tell him to be keep running, even says user navigate to other page and return back, I need the time cookie in the same session. So, this is the object will be created in this bag bean it will be stored in the session of the application Alice So, if we lose our MC look out and log in again.
So, this is a new session. So to start the beginning from again from beginning from zero again. So, in end of page you can have multiple back been so but for this kind of information I need to be always available during the user using system and decision scope. So I will make the scope of sis p to be in the session scope. Okay and him is that his attribute seconds our ticket tickets and this is will be The same might be minutes will take just this is number of movies okay to me exist that to be always okay. So, let us now add the code which will generate this time so I will navigate here in the pain and I will right here private void just time Hear private and get in between these count This is a two methods want to calculate the time and we want to calculate the number of employees.
Okay Here is the actual employee count. I add here, select the segment selected count from an MBE. So I will define Java to the secure the connection, Java secure the revert statement results set, then I will get a connection if you find the connection here I create it would look up to the data source, each RDS which is defined in the WebLogic level. So, now, in this function actually well what we'll do is get an employee count it we'll call the database gets a count of the MVP and To the result, this is what actually this function will do. Second thing we need to implement is adjusted time. So we have to define here private integer.
Second, private integer, minutes. Okay. And in constructor we can just initialize is seconds equals zero minutes equals zero. Okay. And here we say can call seconds, plus plus it will increase one and if second This is 10 we will sit right here, second elbow thickest, so I will get second Oh we'll take a sensitive value. Don't sit value zero plus a second and return.
Okay. So if it's second greater than 9am second This 60 Okay, we will sit it Oh, the second one will take us to is the seconds itself. If seconds equals equals 60 we will return in seconds equal zero and minutes plus plus we will increase the minutes and we sit second second and we would check again if the minutes is 10 sit mean this would take just zero plus minutes and return city value here should get get him in so tickets are city value like this and if minutes greater than nine minutes is sick st can sit minutes exists okay this is just assemble how you can displace seconds and minutes okay. So, now I need to call this function every one second how you can do this there are a div component called ball we will add it here in the page. So I will insert it here if component call Paul this component this component will run the listener of this component every interval he will decide it.
So, I press OK with a property Come on, you will find here the interval is 5000 if it is less than zero it means it is disabled. So, if you want to disable this pool you can add here minus one for example to this one will stop, but here you is the time will be there millisecond it means if I add 1000 it means it is one second now. So, I need the interval to be 1000 it means every one second and here you will find the full list of bull listener which is the code which will be executed every one second. So, in the bull listener here, I will add the function here in the bean born listener okay. And from this poor listener I need to cold adjust time and I need to sit Sorry yes we can we can add here we already added yes number of employees.
So can add a call here get a number with a number we do city value sitting value with get you to go like this. So every one second this code will be executed so it will go and adjust time so it will adjust our tickets and after that it will call and get it number of employees it in value and we'll set a number of employee from this function Okay Okay. So, now let us just refresh this from the board. So, I will take the be one here and I will add it here as a beach as a bunch of triggers so that it will refresh this every one second this part of the beach will be refreshed one want to sink I just want to make a change here for the minutes this minute I just we need to edit here as well inside sit second here and here as was just guess, okay so now let us try to run and see Beach wind looks like okay as you can see here, the Bible is a start now refresh automatically 567 every second and here's a number from Billy he is 107 so let's now try to go to the database level and it's certainly even better we can see is this number will automatically refreshed.
So I will go to the database here and I will add a new employee number images is just for test and me to eat and shop and let's commit and back to the beach. Find here it is 108 whatever Again, I don't really want all night. So, here once that is inserted database, automatically insert export the number will be refreshed and as you can see every one second here the data is refreshed like this. This is how you can make automatic refresh in EDF application, you should use the ball component and you can define the interval and the Boo listener will go and execute it and the code inside the pod listener function this is one of the features if negativity We'll go to the other features to see the activity