Hello, in this video we will try to write the login action code which will check the username and password and if it is correct it will log into the page and displays the dashboard. If it is wrong it will it will give you an error message. So, here our login page and this is our login button initially user name should be required. So, in the behavior here required you can set it as a true password same is required and should you set it to be true and the buzzword should be secret. So in the appearance here, you will sit secret Through. Okay, so to get the value of the username and password once the user press login in the back pain, there are two ways I will simply now I'll tell you about one way where the finish is which we will use is I will bind this component to the back beam.
So, to do that, to add this component back pain, so that you can access this component in the back pain. If component is advancing, you will find here binding it mean. It means carried an object of this component in my bag bean so that I can programmatically make some change and it gives a value or says the value of this component. So in the user name here binding, I will edit management I would create a new manage been called a login philosophy Login beam and package will be view dot been a property will be user name in both tickets thickest so here's the will check it is set it or not. So, this was selected login username input text so I bind now this component in this back pain so in the back pain you will find us on a member tickets enrich in both tickets to component to that you will be able to make some manipulation or change on it.
Okay, we will do the same as a password so in the password I will go to the pointing and I would it select my back been and I carry You property I will call it password input text okay this is for username and password for login we need an action to enter the back pain so I will select my back pain and they the message will be login action in your name can see login action. So in the look in action here now in this talk in action we should write the code which will check the username and the password. So, first we can make a try and catch and we should try we will get the user name and password so I will write drink user Name equal. We will get it from the user name in particular, it's a binding. So I will say this is the input tickets dot.
Get ID value. Don't just drink. Drink password equal. I will not check if it is null or not because Anyway, I'll use it the required withdrew. So here's a password input tickets. Don't get to value.
Don't drink. So now we receive a username and password if you want just to print it to be sure you get it correctly. So user name user name Okay then after that we have to check the connector database and check as the username and password is correct or not so I will create here prepared statement okay is t equal now okay reason sit or is equal now exists so I think okay insert Java SQL statement this and insert prepared statement as well. Here I would define my SQL statement. So I think SQL equals we should write our SQL statement furnace first we need to define the connection. So connection con equal null.
So here after you find the select statement, erasure of SQL, here I will set the connection equal and common here my ID if you till I create connections, there is a connection here. You Connection method, which you get the connection from the data source called a school. So we have to define this data source in the WebLogic. So that the logging can access the data source, I will show you how you can create this data source. We will create it in ways that have a source way before deploying our ADF application. So here's the connection, we can get it from my if you take a look at the connection, it imports the connection here, my ADF you to look good connection.
So now I get the connection. Then in the state equal connection, Very beer misstatement SQL okay we can add this and try and catch here. After that we can say R is equal to execute query in wire RS dot execute is next it means the username and the password is correct So here I will try to set some variables in the session scope. As I told you in the filter here we use the user name and the filter in the session scope. So what it is okay I will just distort this so you see my ad if you don't, there is a function to button sitter positions if key will be my username and the object will be username like this Okay, so after that we will move to the dashboard as an outcome, your dashboards Okay, so if it is not correct, okay, or any exception, okay, we can display here my ad You don't show error message invalid username or password invalid username or password.
So this review or quit again. Here I will get the username and the password I generate connection gets a connection. Good execute the SQL statement if it is correct, I will set it in the user name and return dashboard. So we need to write this SELECT statement. So we will continue and negativity see you Nick activity