Login Action code is correct or not.Please verify it and if any changes nee
hi i have the login page and i have username and password in my employee table. So i have written my code in this manner. Whether i am correct or not. If any modifications or corrections are needed please help me .I am posting my code below.
String Username = (String) textField1.getText();
String Password = (String) textField2.getText();
try{
RowKey rowkey = employeeDataProvider.getRowKey("SRNI.EMPLOYEE");
employeeDataProvider.refresh();
employeeDataProvider.findAll("SRNI.EMPLOYEE.EMPCODE", rowkey);
boolean ok = (boolean) (Username.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPCODE", rowkey))) && (Password.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPPWD", rowkey)));
if(ok = true)
{
info("Enetered the If block");
return "OldEmployee";
}
}
catch(Exception e){
log("Employee Login Failed " + e);
error("Employee Login Failed" + e.getMessage());
}
return null;
Thank You in Advance.
# 1
String Username = (String) textField1.getText();
String Password = (String) textField2.getText();
RowKey rowkey = employeeDataProvider.getRowKey("SRNI.EMPLOYEE");
try{
employeeDataProvider.refresh();
employeeDataProvider.findFirst("SRNI.EMPLOYEE.EMPCODE", rowkey);
boolean ok = (boolean) (Username.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPCODE", rowkey))) && (Password.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPPWD", rowkey)));
if(ok = true)
{
info("Enetered the If block");
return "OldEmployee";
}
else
{
employeeDataProvider.cursorNext();
return existMember_action();
}
}
catch(Exception e){
log("Employee Login Failed " + e);
error("Employee Login Failed" + e.getMessage());
}
return null;
I have modified to this , but this time also it wont works. Please help me out from this problem
# 2
What seems to be the problem?Should you be doing "ok == true" ?
# 3
Hi deepsix ,
Actually i have two text fields in my login page, one is employee code and employee password. So i am taking the textfields data into the strings username and password. So i am keeping the
employeeDataProvider.cursorForst(); So that the cursor row will be first of the row and then it get the value of the empcode and emp password from the database and compares the username and the database returned value. If it is true then it must enter into the if block otherwise it will once again call the member action in else statement. So that it iterates from first to the last row.
I assumed to be happen what i said above.
Will it be work as i assumed or it wont. Can i use the cursorFirst() method in normal dataProvider or it must be used for the TabledataProvider. Please give me some idea regarding the iteration of whole table rows, how it can do and by what it can be done.
Thank you deepsix, I am waiting for your reply. Please help me out.
Thank You in Advance.
# 4
Hi,
I dont see the cursorFirst statement in your sample code above.
If you want to know how to use data providers please refer the tutorial
http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/dat aproviders.html#07
It gives information on how to use data providers and how to iterate through them using cursors.
If, after reading up on the tutorial carefully, you have any more questions, please
do post them here
HTH
# 5
Hi deepsix,
I have gone through the said tutorial, but even over there also what i done is similar to it but still i dont get it. Please any help would be appreciated. Really i am struggling with this problem.
Atleast judge wheter my code is correct or not. If any changes to be made please make it.
Here i am posting my code once again for your reference.
String Username = (String) textField1.getText();
String Password = (String) textField2.getText();
RowKey rowkey = employeeDataProvider.getRowKey("SRNI.EMPLOYEE");
try{
employeeDataProvider.refresh();
employeeDataProvider.cursorFirst();
employeeDataProvider.findFirst("SRNI.EMPLOYEE.EMPCODE", rowkey);
boolean ok = (boolean) (Username.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPCODE", rowkey))) && (Password.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPPWD", rowkey)));
if(ok == true)
{
info("Enetered the If block");
return "OldEmployee";
}
else
{
info("Entered The Else Block");
employeeDataProvider.cursorNext();
return existMember_action();
}
}
catch(Exception e){
log("Employee Login Failed " + e);
error("Employee Login Failed" + e.getMessage());
}
return null;
Thank You in Advance.
# 6
Hi deepsix,
I have gone through the said tutorial, but even over there also what i done is similar to it but still i dont get it. Please any help would be appreciated. Really i am struggling with this problem.
Atleast judge wheter my code is correct or not. If any changes to be made please make it.
Here i am posting my code once again for your reference.
Public existMember_action(){
String Username = (String) textField1.getText();
String Password = (String) textField2.getText();
RowKey rowkey = employeeDataProvider.getRowKey("SRNI.EMPLOYEE");
try{
employeeDataProvider.refresh();
employeeDataProvider.cursorFirst();
employeeDataProvider.findFirst("SRNI.EMPLOYEE.EMPCODE", rowkey);
boolean ok = (boolean) (Username.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPCODE", rowkey))) && (Password.equals(employeeDataProvider.getValue("SRNI.EMPLOYEE.EMPPWD", rowkey)));
if(ok == true)
{
info("Enetered the If block");
return "OldEmployee";
}
else
{
info("Entered The Else Block");
employeeDataProvider.cursorNext();
return existMember_action();
}
}
catch(Exception e){
log("Employee Login Failed " + e);
error("Employee Login Failed" + e.getMessage());
}
return null;
}
Thank You in Advance.
# 7
Hi Srinivasan,
It would really help if you were to describe what exactly the problem is.
Arent you able to traverse through the rows of your database?
Doesnt the equal to check come out fine?
Does an exception occur when you run the code?
Why is this "ok" variable created instead of directly putting the statement inside
an if conditional statement.
# 8
http://forum.java.sun.com/profile.jspa?userID=672992The above link suggests that you might be more productive if you took some time out and studied the available reference and learning material.