1

Well, I'm developing a app in my cellphone that is going to connect to my PC, the problem is that everytime that I return a URLRequest to the cellphone, it shows the previous Form on the screen and not de actual one, for example this is what goes in my actionListener:

public void actionPerformed(ActionEvent ae) {
    if (ae.getCommand() == guiaUtil.cSelecionar()) {
        LoginRemote loginRemote = new LoginRemote();

        try {
            //This is the request, returns true or false, does not affect the form
            loginRemote.login(tLogin.getText(), tPassword.getText());
        } catch (Exception e) {

            GuiaUtil.error(e);
            return;
        }
        guiaUtil.mainApp().startMenu();
    }

}

Then in the "guiaUtil.mainApp().startMenu()" I have this

public void startMenu() {
    if (itemsMenu == null) {
        itemsMenu = new List();
        itemsMenu.setWidth(320);

        itemsMenu.addItem("Sincronize Spots");
        itemsMenu.addItem("Find Spots");
        itemsMenu.addItem("Work");
        itemsMenu.setFocus(true);

        this.addComponent(itemsMenu);
        this.addCommandListener(this);
        this.addCommand(guiaUtil.cSelect());
        Form form = new Form();
        form.addComponent(itemsMenu);

    }
    form.show();

}

Anyway, after the request returns, it shows my Login form again, instead of showing the Menu List

Andre Mariano
  • 308
  • 1
  • 3
  • 14

3 Answers3

1

Maybe what is going is that you are getting an exception, treating it with GuiaUtil.error and returning from actionPerformed without calling startMenu.
I would move guiaUtil.mainApp().startMenu() inside the try/catch block.

Telmo Pimentel Mota
  • 4,033
  • 16
  • 22
0

You have to put the following code outside the if condition.

Form form = new Form();
form.addComponent(itemsMenu);

You are having two form object. one inside if and another one outside of if. Object created inside the loop will loses the scope inside if. You are showing form object outside if. That's why, menu list screen was not displayed.

Kalai Selvan Ravi
  • 2,846
  • 2
  • 16
  • 28
0

Not sure what happens in loginRemote.login(tLogin.getText(), tPassword.getText()); If you access the network, I would put that part in a different thread. Inform the main thread by some kind of callback when the "remote login" is done, you can show the menuForm from the edt then.

endevour
  • 708
  • 4
  • 12