Я создаю приложение в J2ME. У меня есть один Loginpage
и SearchingAccount
.J2ME: перенаправить на страницу оповещения
Вставьте AlertSuccess
и AlertFailure
между этими двумя страницами. Если пользователь успешно зарегистрирован
он перенаправляет на AlertSuccess
после нажатия на предупреждение он перенаправляет на SerachAcount
.
Я делаю это успешно, но когда пользователь вводит неверные данные, то мне нужно показать AlertFailure
и показать снова страницу входа в систему, но мое приложение показывает AlertSuccess
и отображает SearchAccount
страницу, даже если пользователь вводит неверные данные.
Я пробовал много, но не добился успеха. Пожалуйста, дайте мне какой-нибудь намек на то, как это сделать.
Вот мой MIDlet экран потока:
Вот мой код для справки.
} else if (displayable == Login) {
if (command == Login1) {
u_Name=txtUserId.getString();
u_Password=txtPassword.getString();
readUserRecords(u_Name, u_Password);
switchDisplayable(null, getWaitScreen());
public void readUserRecords(String userName,String Password){
try{
byte[] recData = new byte[5];
int len;
for(int i = 1; i <= rs.getNumRecords(); i++){
if(rs.getRecordSize(i) > recData.length){
recData = new byte[rs.getRecordSize(i)];
}
len = rs.getRecord(i, recData, 0);
String str= new String(recData,0,len);
s=str.indexOf(userName);
s1=str.indexOf(Password);
splitUserRecord(str);
System.out.println("User Login Page--------------------------------------");
System.out.println("---index of string-------"+s+" and "+s1);
if(u_id.equals(u_Name)&& u_pass.equals(u_Password))
{
System.out.println("UserLogin Successfully "+str);
alertSuccess = new Alert("OK", "You are Login Successfully!",
successimg, AlertType.INFO);
alertSuccess.setImage(successimg);
display.setCurrent(alertSuccess, Login);
}
else
{
System.out.println("Enter Wrong user name");
alertFailure = new Alert("Cancel", "Enter correct user name and password!",failureimg, AlertType.INFO);
System.out.println("Enter Wrong user name1");
alertFailure.setImage(failureimg);
System.out.println("Enter Wrong user name2");
display.setCurrent(alertFailure, Login);
System.out.println("Enter Wrong user name3");
// getAlertFailure();
}
}
}catch (Exception e){}
}
public Alert getAlertFailure() {
if (alertFailure == null) {
alertFailure = new Alert("alert");
alertFailure.setTimeout(Alert.FOREVER);
alertFailure.setImage(failureimg);
display.setCurrent(alertFailure,Login);
}
return alertFailure;
}
public Alert getAlertSuccess() {
if (alertSuccess == null) {
alertSuccess = new Alert("alert1");
alertSuccess.setTimeout(Alert.FOREVER);
}
return alertSuccess;
}
эй спасибо ... это очень просто, но решить мою проблему. –