-
Calling a boolean Attribute from another class
Code:
public class validateLogin{
public boolean validate(String username, String password) {
boolean state = false;
if(username.equals(user) && password.equals(pass))
{
state = true;
}
else
state =false;
}
}
return state;
}
Then I create a page where the username and the password are going through and the above class is just validate. If the state is true the user will be redirected to another page; however, I don't know how to call the state attribute and put it in an if statements. I create an object and call the validate method know I want to create and if statement .
ValidateLogin v = new ValidateLogin();
v.validate(username, password);
if(state = true) //HOW DO I CALL THIS ATTRIBUTE THAT IS IN ANOTHER CLASS?
redirect to page
-
I had the same problem. In order to modify variables from different classes, I made them extend the class they were to modify. I also made the super class's variables static so they can be changed by anything that inherits them. I also made them protected for more flexibility.
-
Hi, can anyone resolve this problem yet? Recently I have an on-going project that needs to do, and I also have this same issue. Now I have to try another one to keep my project on the way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|