Java me J2ME:重定向到警报页面
我正在用J2ME创建一个应用程序。我有一个Java me J2ME:重定向到警报页面,java-me,alert,midp,lcdui,Java Me,Alert,Midp,Lcdui,我正在用J2ME创建一个应用程序。我有一个登录页面和搜索账户页面 我在这两页之间插入了AlertSuccess和AlertFailure。如果用户成功登录 他重定向到AlertSuccess点击警报后,他重定向到serachaccount页面 我成功地做到了这一点,但当用户输入不正确的详细信息时,我需要显示AlertFailure并再次显示登录页面,但我的应用程序显示AlertSuccess并显示SearchAccount页面,即使用户输入了不正确的详细信息 我试了很多,但没有成功。请告诉我怎么
登录页面
和搜索账户
页面
我在这两页之间插入了AlertSuccess
和AlertFailure
。如果用户成功登录他重定向到
AlertSuccess
点击警报后,他重定向到serachaccount
页面
我成功地做到了这一点,但当用户输入不正确的详细信息时,我需要显示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;
}
}else if(可显示==登录){
如果(命令==Login1){
u_Name=txtUserId.getString();
u_Password=txtPassword.getString();
readUserRecords(u_名称、u_密码);
switchDisplayable(null,getWaitScreen());
public void readUserRecords(字符串用户名、字符串密码){
试一试{
字节[]recData=新字节[5];
内伦;
for(int i=1;i recData.length){
recData=新字节[rs.getRecordSize(i)];
}
len=rs.getRecord(i,recData,0);
String str=新字符串(recData,0,len);
s=str.indexOf(用户名);
s1=str.indexOf(密码);
splitUserRecord(str);
System.out.println(“用户登录页-------------------------------------------------------------”);
System.out.println(“----字符串索引----“+s+”和“+s1”);
if(u_id.equals(u_Name)和&u_pass.equals(u_密码))
{
System.out.println(“用户登录成功”+str);
alertSuccess=新警报(“确定”,“您已成功登录!”,
successimg,AlertType.INFO);
alertSuccess.setImage(successimg);
display.setCurrent(alertSuccess,Login);
}
其他的
{
System.out.println(“输入错误的用户名”);
alertFailure=新警报(“取消”,“输入正确的用户名和密码!”,failureimg,AlertType.INFO);
System.out.println(“输入错误的用户名1”);
alertFailure.setImage(failureimg);
System.out.println(“输入错误的用户名2”);
display.setCurrent(警报失败,登录);
System.out.println(“输入错误的用户名3”);
//getAlertFailure();
}
}
}捕获(例外e){}
}
公共警报getAlertFailure(){
如果(alertFailure==null){
alertFailure=新警报(“警报”);
alertFailure.setTimeout(Alert.FOREVER);
alertFailure.setImage(failureimg);
display.setCurrent(警报失败,登录);
}
返回故障;
}
公共警报getAlertSuccess(){
if(alertSuccess==null){
alertSuccess=新警报(“警报1”);
alertSuccess.setTimeout(Alert.FOREVER);
}
回归成功;
}
如果我是对的,您的代码是自动生成的。您需要手动编写所有代码,然后只需单击命令调用函数(将显示下一个表单)
在这个表单中,您应该编写display.setCurrent(表单名称)
。但不要忘记将小部件附加到特定表单中