×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    1

    Back Command not working in all page

    Hi All,

    I'm new to Java Me Programming and hope some light could be shed.
    My back command only works in my 'Write' page and not the 'read' and 'search' pages.
    Please help me out.

    My code is as followed :

    Code:
    import java.io.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;
    
    public class MovieBookingMidlet extends MIDlet implements CommandListener
    {
        private RecordStore rs = null;					// Record store
        private Display display;						// Reference to Display object
        private List menu;								// List object reference
        private Form writeForm;							// Write records screen
        private Form readForm;							// Read records screen
        private Form deleteForm;						// Delete records screen
        private Form searchForm;						// Search records screen
        private TextField textName;						// Input name
    
       private ChoiceGroup Movie;
      // private DateField date;
        //private TextField textDate;					// Input phone
        //private TextField textCategory;
       // private TextField textStatus;
        private TextField textSearch;					// Input search
        private Command backCommand = new Command("Back", Command.BACK, 1);
        private Command deleteCommand = new Command("Delete", Command.EXIT, 1);
        private Command exitCommand = new Command("Exit", Command.EXIT, 1);
        private Command writeCommand = new Command("Write", Command.OK, 1);
        private Command findCommand = new Command("Find", Command.OK, 1);
        static final String REC_STORE = "db_lab10";		// Name of record store
        private TextField textPhone;
        private TextField textMovie;
    
        
        private String movieName;
        private ChoiceGroup timing;
        private String Timing;
        
        private ChoiceGroup date;
        private String mDate;
    
        private ChoiceGroup NoTic;
        private String noTic;
        public MovieBookingMidlet()
        {
            // create a list menu
            menu = new List("Movie  Booking", Choice.IMPLICIT);
            menu.append("Book", null);
            menu.append("View", null);
            menu.append("Delete", null);
            menu.append("Search", null);
    
             Movie = new ChoiceGroup("Select Movie", Choice.EXCLUSIVE);
                        Movie.append("Titanic", null);
                        Movie.append("X-Men",null);
    
            // add an exit command & register command listener for list menu
            menu.addCommand(exitCommand);
            menu.setCommandListener(this);
        }
    
        public void destroyApp(boolean unconditional)
        {
            // Close record store
            closeRecStore();
    
            // Remove the record store
            // deleteRecStore();
    
            menu = null;
            writeForm = null;
        }
    
        public void startApp()
        {
            // Create the record store
            openRecStore();
    
            // Read back the records
            // readStream();
    
            // get reference to Display object
            display = Display.getDisplay(this);
    
            // set list menu visible
            display.setCurrent(menu);
        }
    
        public void pauseApp()
        {
        }
    
        public void commandAction(Command c, Displayable d)
        {
            Alert alert;
    
            if (d == menu)
            {
                if (c == List.SELECT_COMMAND)
                {
                    int selectedIndex = menu.getSelectedIndex();
    
                    // debugging only
                    // System.err.println(menu.getString(selectedIndex));
    
                    if (menu.getString(selectedIndex).equals("Book"))
                    {
    
                        // try to dispose of write form first
                        writeForm = null;
    
                        // create a form for write records screen
                        writeForm = new Form("Book Movies");
    
                        // create 2 TextFields for write records screen
                        textName = new TextField("Name:", "", 50, TextField.ANY);
                        textPhone = new TextField("Phone No:", "", 9, TextField.NUMERIC);
    
                        date = new ChoiceGroup("Select Available Date", Choice.POPUP);
                        date.append("23/1/11", null);
                        date.append("24/1/11",null);
                        date.append("25/1/11",null);
                        date.append("26/1/11",null);
    
                        timing = new ChoiceGroup("Select timing", Choice.POPUP);
                        timing.append("7pm", null);
                        timing.append("9pm",null);
                        timing.append("11pm",null);
                        timing.append("1am",null);
    
                        Movie = new ChoiceGroup("Select Movie", Choice.POPUP);
                        Movie.append("Titanic", null);
                        Movie.append("X-Men",null);
                        Movie.append("Transformer",null);
                        Movie.append("Harry Porter",null);
    
                        NoTic = new ChoiceGroup("No Of Tickets", Choice.POPUP);
                        NoTic.append("1", null);
                        NoTic.append("2", null);
                        NoTic.append("3", null);
                        NoTic.append("4", null);
                        NoTic.append("5", null);
                        NoTic.append("6", null);
                        NoTic.append("7", null);
                        NoTic.append("8", null);
                        NoTic.append("9", null);
                        NoTic.append("10", null);
    
    
                        writeForm.append(textName);
                        writeForm.append(textPhone);
    
                        writeForm.append(date);
                        writeForm.append(timing);
                        writeForm.append(Movie);
                        writeForm.append(NoTic);
    
                        // add a back command & register command listener for write records screen
                        writeForm.addCommand(backCommand);
                        writeForm.addCommand(writeCommand);
                        writeForm.setCommandListener(this);
    
                        // set write form visible
                        display.setCurrent(writeForm);
                    }
                    else if (menu.getString(selectedIndex).equals("View"))
                    {
                        // try to dispose of read form first
                        readForm = null;
    
                        // create a form for read records screen
                        readForm = new Form("View Bookings");
    
                        // add a back command & register command listener for read records screen
                        readForm.addCommand(backCommand);
                        readForm.setCommandListener(this);
    
                        // print out the results to the screen
                        int count = readRecordStore(readForm);
    
                        if (count == 0)
                        {
                            alert = new Alert("Info", "No Bookings are found.", null, AlertType.INFO);
                            display.setCurrent(alert, menu);
                        }
                        else
                        {
                            // set read form visible
                            display.setCurrent(readForm);
                        }
                    }
                    else if (menu.getString(selectedIndex).equals("Delete"))
                    {
                        // try to dispose of delete form first
                        deleteForm = null;
    
                        // create a form for delete records screen
                        deleteForm = new Form("Delete Records");
    
                        // create 2 TextFields for delete records screen
                        textName = new TextField("Name:", "", 50, TextField.ANY);
                        textPhone = new TextField("Phone:", "", 9, TextField.NUMERIC);
                        textMovie = new TextField("Movie","",50, TextField.ANY);
    
    
                        // append 2 TextFields for delete records screen
                        deleteForm.append(textName);
                        deleteForm.append(textPhone);
                        deleteForm.append(textMovie);
    
    
                        // add a back command & register command listener for delete records screen
                        deleteForm.addCommand(deleteCommand);
                        deleteForm.addCommand(backCommand);
                        deleteForm.setCommandListener(this);
    
                        // set delete form visible
                        display.setCurrent(deleteForm);
                    }
                  
        }

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    376

    Re: Back Command not working in all page

    IS your commandAction() handling the back command i cant see any such code ?? add the cases to make your backcommand work i.e for hadling the search forms back command add it as if (displayable=="search"){//code for backcommand}

  3. #3
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    Re: Back Command not working in all page

    check have set command listener for every form, & if yes then check have you add on form.

    check any action get perform or not on button...use simple System.out.println() for trace your code.
    thanks & Regards.
    Nilesh

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Back Command not working in all page

    Are any other command working then Back?

    Instead of checking if (d == menu), You should check like this if (d instanceof menu).

    And you have not checked the condition for the Back command, please check and code. Add the condition for the back command.
    check and revert.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Back up and Restore not working - any experts out there?
    By matthewjtennant in forum Symbian C++
    Replies: 3
    Last Post: 2010-06-11, 20:34
  2. jQuery, HTML page (not wgz), JS not working
    By rkoberg in forum Symbian Web Runtime
    Replies: 1
    Last Post: 2010-05-30, 12:51
  3. OfferKeyEventL is not working for back button
    By abhi560 in forum Symbian C++
    Replies: 2
    Last Post: 2009-07-03, 10:36
  4. Call back function not working
    By sram_mohan in forum Symbian C++
    Replies: 1
    Last Post: 2008-05-27, 13:51
  5. voice command not working in 6600 a bug?
    By ravi_lakhani in forum Symbian C++
    Replies: 7
    Last Post: 2003-12-28, 19:09

Posting Permissions

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