2012-05-07 7 views
2

私はJ2MEでアプリケーションを作成しています。私にはLoginpageSearchingAccountページがあります。J2ME:アラートページにリダイレクト

この2ページの間にAlertSuccessAlertFailureを挿入します。ユーザーが正常にログインした場合
彼はAlertSuccessにリダイレクトします。警告をクリックすると、SerachAcountページにリダイレクトされます。

私は正常にこの操作を行うが、ユーザが不正な詳細情報を入力したとき、私はAlertFailureを表示する必要があり、ページのログインを再び示すが、自分のアプリケーションがAlertSuccessを示しており、ユーザーが不正な詳細を入力してもSearchAccountページが表示されます。

私はたくさん試しましたが、成功しませんでした。これを行う方法について私に何か示唆を与えてください。ここに参照のための私のコードは Here is my MIDlet flow screen.

です:

は、ここに私の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; 
} 

答えて

2

私が正しいとすれば、あなたのコードは自動生成されます。あなたは手動ですべてのコードを書いてからCommand(次のフォームを表示する)をCommandクリックで呼び出す必要があります。

このフォームの中には、display.setCurrent(Form Name)と書く必要があります。しかし、特定のフォームにウィジェットを追加することを忘れないでください。

+0

おかげさま...とてもシンプルですが、私の問題を解決してください。 –