public String verifyUser2(){
ArrayList<User> users = new ArrayList<User>(service.getUsers());
String dir ="error";
boolean found = false;
int i = 0;
while(!found && i < users.size()){
User u = users.get(i);
System.out.print(u.getName());
System.out.print(u.getPassword());
System.out.println(name);
System.out.println(password);
if(u.getName().equals(name) && u.getPassword().equals(password)){
found = true;
dir="welcome";
}
else{
i++;
}
}
System.out.println(found);
return dir;
}
And the way I call it is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>#{msgs.title}</title>
</h:head>
<h:body>
<h:form>
<h3>#{msgs.heading}</h3>
<table>
<tr>
<td>#{msgs.hName}</td>
<td><h:inputText value="#{userBean.name}"/></td>
</tr>
<tr>
<td>#{msgs.hPassword}</td>
<td><h:inputSecret value="#{userBean.password}"/></td>
</tr>
</table>
<p><h:commandButton value="#{msgs.login}" action="#{userBean.verifyUser2}"/></p>
</h:form>
</h:body>
</html>
But for some reason I newer find the user and I use the sysout's to check if the username and password is the correct once and from what I can se I do type in the correct one. Can anyone tell me why I never get true returned. Am I calling something wrong or what?
Pleas tell if you need more of my code

New Topic/Question
Reply


MultiQuote



|