×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Sep 2011
    Posts
    73

    An alert is not displaying.

    Below is an excerpt that involves searching for a match. When there is a match, the console successfully displays "There is a match." twice, but the alert does not display. Might anyone have any insights in that regard?

    Code:
    	// Read from and perform a search filter on the record store.
    	String strTheRecord = null;
    	try{
    		if (sortedUserChoicesTestDb.getNumRecords() > 0) {
    			//RecordFilter SearchFilter = new SearchFilter("Sample 2");
    			//String strTheSearchString = "cHoice 3";
    			String strTheSearchString = strNewChoice;
    			RF searchFilter = new RF(strTheSearchString);
    			RecordEnumeration reTestEnumeration = sortedUserChoicesTestDb.enumerateRecords(searchFilter, null, false);
    			while (reTestEnumeration.hasNextElement()) {//xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    				try {
    					strTheRecord = new String(reTestEnumeration.nextRecord());
    				} catch (RecordStoreException ex) {
    					ex.printStackTrace();
    				}
    			}
    			if (strTheRecord != null) {
    				System.out.println("There is a match.");				
    				alert = new Alert("Record Possibly Exists Already",  
    								  "Entered record:  " + strTheRecord + "\n" + 
    								  "Existing record:  " + strTheSearchString + "\n" +
    								  "(same spelling, different capitalization)\n" +
    								  "Continue or cancel?", null, AlertType.WARNING);
    				alert.setTimeout(Alert.FOREVER);
    				alert.setCommandListener(this);
    				display.setCurrent(alert);			
    				System.out.println("There is a match.");				
    			} else {
    				System.out.println("There is not a match.");				
    			}
    			System.out.println("------------------------------");
    			System.out.println("The matching record is " + strTheRecord + ".");                  
    			System.out.println("------------------------------");
    		}
    	} catch (RecordStoreNotOpenException ex) {
    		ex.printStackTrace();
    	}

  2. #2
    Regular Contributor
    Join Date
    Sep 2011
    Posts
    73

    Smile Re: An alert is not displaying.

    I found the cause. Somewhere else in the code was the below line, which caused the main screen to load.

    Code:
    display.setCurrent(screen);
    When the main screen loaded, the alert screen was no longer visible. This all occurred so quickly that I couldn't see the alert screen.

Similar Threads

  1. Displaying the alert in 3 seconds
    By sweetsweet24 in forum Mobile Java General
    Replies: 5
    Last Post: 2009-05-13, 08:37
  2. Displaying Alert
    By blackspear in forum Mobile Java General
    Replies: 1
    Last Post: 2007-01-16, 10:42
  3. Alert not displaying
    By dhanyap in forum Mobile Java General
    Replies: 2
    Last Post: 2006-11-20, 16:45
  4. displaying an Alert
    By KNovA in forum Mobile Java General
    Replies: 0
    Last Post: 2005-03-08, 16:00
  5. Displaying Alert in MIDP1
    By anand_amarsh in forum Mobile Java General
    Replies: 2
    Last Post: 2004-12-28, 07:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×