Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

J2ME Problem

Options
  • 15-05-2009 11:25pm
    #1
    Registered Users Posts: 269 ✭✭


    I have developed a simple J2ME app that allows a user enter an employees number and and get back there record from a web servicde however i enter the number press submit this message comes up which is normal however nothing happens only this message freezes there


    Can anyone help

    //jad file (please verify the jar size)
    /*
    MIDlet-Name: TextFieldCapture
    MIDlet-Version: 1.0
    MIDlet-Vendor: MyCompany
    MIDlet-Jar-URL: TextFieldCapture.jar
    MIDlet-1: TextFieldCapture, , TextFieldCapture
    MicroEdition-Configuration: CLDC-1.0
    MicroEdition-Profile: MIDP-1.0
    MIDlet-JAR-SIZE: 100
    
    */
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.midlet.MIDlet;
    import ie.travel.webservice.*;
    
    public class TextFieldCapture extends MIDlet implements CommandListener {
      private Display display;
      private AdministrationService_Stub admin;
      private Form form = new Form("Find Employee");
    
      private Command submit = new Command("Submit", Command.SCREEN, 1);
    
      private Command exit = new Command("Exit", Command.EXIT, 1);
    
      private TextField textfield = new TextField("Employee Number", "", 30, TextField.ANY);
    
      public TextFieldCapture() {
        display = Display.getDisplay(this);
        form.addCommand(exit);
        form.addCommand(submit);
        form.append(textfield);
        form.setCommandListener(this);
        admin= new AdministrationService_Stub();
      }
    
      public void startApp() {
        display.setCurrent(form);
      }
    
      public void pauseApp() {
      }
    
      public void destroyApp(boolean unconditional) {
      }
      
      public void webservice(TextField textfield)
      {
    	   
      }
    
      public void commandAction(Command command, Displayable displayable) {
        if (command == submit) {
        	try{
      	      textfield.setString(textfield.getString());
      	      String employee = textfield.getString();
      	      System.out.println(employee);
      	      String result=admin.getEmployee(employee);
      	      System.out.println(result);
      	      textfield.setString(result);
      	      }catch(Exception ex){
      	    	  textfield.setString("error" + ex);  
      	      } 
          form.removeCommand(submit);
        } else if (command == exit) {
          destroyApp(false);
          notifyDestroyed();
        }
      }
    }
    
    


    ** Check attachment for message


Comments

  • Registered Users Posts: 1,916 ✭✭✭ronivek


    Just checking you are clicking okay on the emulator to allow it to continue; right?


  • Registered Users Posts: 269 ✭✭cyberwit


    I did but nothing happens the message just continues to show


  • Registered Users Posts: 3,945 ✭✭✭Anima


    Are you sure it can connect ok? Check the proxy settings for the emulator.


  • Registered Users Posts: 269 ✭✭cyberwit


    I have changed the code and i can now access my webservices through the J2ME however i have installed the app on my mobile phone how can i access the web services throught the app on my mobile phone if my web services are hosted locally on my laptop


  • Registered Users Posts: 3,945 ✭✭✭Anima


    You'll need to get your internet ip (not the 192.168.0.x), http://www.whatismyip.com/, and put that into your MIDlet to connect to. You might have to change some firewall settings to make the web services on your laptop available to the outside world.

    You're probably better off using the emulator if you're still in development.


  • Advertisement
Advertisement