×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    7

    Can we make this into a form

    Hi,

    The foll code which displays a message form to the user who types in as much text he wants to and thereafter submits it at the server end.
    My doubt is – can this code be used to make a form i.e. Can text boxes/multiple options be inserted in this eg. For taking in name, marks, choose category etc. as inputs by the user so that data comes on a server in a consistent format?

    Please let me know as to how that can be done.


    public class MessageForm extends TextBox
    implements CommandListener {

    private Command submit;
    private Command cancel;

    public MessageForm () {
    super ("Message", "", 250, TextField.ANY);

    submit = new Command ("Submit", Command.OK, 1);
    cancel = new Command ("Cancel", Command.CANCEL, 1);
    addCommand (submit);
    addCommand (cancel);
    setCommandListener (this);
    }

    public void commandAction (Command c, Displayable d) {
    if (c == submit) {
    Client.message = getString();
    Client.startSubmit ();

    } else if (c == cancel) {
    Client.initSession();

    }
    }

    }

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

    Re: Can we make this into a form

    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Can we make this into a form

    Please ref to: http://developers.sun.com/mobility/m.../midp2network/

    This page has email sending j2me example, it will help you.

    thanks,
    ~Amitabh

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    7

    Re: Can we make this into a form

    A big Thank-you to both of you for your kind pointers.I did read through the links. Unfortunately, I'm still not able to fathom how to include the textboxes in the login screen when it is not a part of the midlet, but the second screen of the application instead.

    I tried running the foll code., it compiled fine, but again only a message box appeared and the loginname and password text box fields were not appended to that form.

    Pl. correct me and explain to me what is the error in the foll code:



    package com.Series40Book;

    import javax.microedition.lcdui.*;


    public class MessageForm1 extends TextBox
    implements CommandListener {

    private Command submit;
    private Command cancel;
    private StringItem si;
    private Form f;
    private TextField userName;
    private TextField password;

    public MessageForm1 () {
    super ("Message", "", 250, TextField.ANY);

    f = new Form("Email Client");
    si = new StringItem("Response:" , " ");
    f.append(si);
    userName = new TextField("LoginID:", "", 10, TextField.ANY);
    password = new TextField("Password:", "", 10, TextField.PASSWORD);
    f.append(userName);
    f.append(password);

    submit = new Command ("Submit", Command.OK, 1);
    cancel = new Command ("Cancel", Command.CANCEL, 1);
    addCommand (submit);
    addCommand (cancel);
    setCommandListener (this);
    }

    public void commandAction (Command c, Displayable d) {
    if (c == submit) {
    Client.message = getString();
    Client.startSubmit ();

    } else if (c == cancel) {
    Client.initSession();

    }
    }

    }

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

    Re: Can we make this into a form

    Hi,

    You are not painting/drawing or setting the current displayable as the form.I dont know why you are doing this like you have written in the code.Just simply do it like this,
    1.create a midlet
    2.Take a form
    3.create the textfields,command or whatsoever you wanna draw on the form
    4.append all the created entities on the form
    5.set the form as the displayable.

    I guess you have not even try to read the code posted over the previous posts.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Registered User
    Join Date
    Feb 2009
    Posts
    7

    Re: Can we make this into a form

    I did read through the login example and the other links. I'm new to J2ME and the first assignment I had got very recently was to make a login form :-) Sorry, I think I did not state my problem clearly.



    I have only developed midlets for performing simple operations like login etc. But now, I’m confused as to how to go about solving this problem assignment which has been given to me.

    There is a Midlet which has function calls for displaying various screens of the J2ME app all of which have different functionalities. The Midlet code is given below:

    Code:
    “
    public class Client extends MIDlet {
      public static Display display;
      private static Client controller;
    
      static int NO_OBJECT = 0;
        public static String message;
      public static String photoType = "png";
    
      public Client () {
        display = Display.getDisplay(this);
        controller = this;
      }
    
      public static void showMessageForm () {
        MessageForm form = new MessageForm ();
        display.setCurrent (form);
      }
    Etc…
    “
    It is calling the class MessageForm which is a text box where the user can enter data in any format . Ive been asked to convert this Message Form class into a Form which takes in user input in separate text fields like Username, Password etc.

    The code for the existing Message form class has been given below.

    Code:
    “
    import javax.microedition.lcdui.*;
    public class MessageForm extends TextBox
                    implements CommandListener {
      private Command submit;
      private Command cancel;
    
      public MessageForm () {
        super ("Message", "", 250, TextField.ANY);
    
        submit = new Command ("Submit", Command.OK, 1);
        cancel = new Command ("Cancel", Command.CANCEL, 1);
        addCommand (submit);
        addCommand (cancel);
        setCommandListener (this);
      }
    
      public void commandAction (Command c, Displayable d) {
        if (c == submit) {
          Client.message = getString();
          Client.startSubmit ();
    
        } else if (c == cancel) {
          Client.initSession();
              }  }
    
    “
    Please help and let me know how to go about solving this problem .


    I tried the foll., without changing the fuction call in the midlet, but it did not work, the point at which this item no. details form should to be displayed, I got a java/lang/nullpointer exception.

    Code:
    import javax.microedition.lcdui.*;
    
    
    public class MessageForm4 extends TextBox
                    implements CommandListener {
    
      private Command submit;
      private Command cancel;
      protected Display display;
    
    public MessageForm4 () {
        super ("Message", "", 250, TextField.ANY);
        Form form = new Form("Item Layout");
    
        form.append("line");
    
        form.append(new TextField("Item no.", null, 8, TextField.ANY));
    
        display.setCurrent(form);
        submit = new Command ("Submit", Command.OK, 1);
        cancel = new Command ("Cancel", Command.CANCEL, 1);
        addCommand (submit);
        addCommand (cancel);
        setCommandListener (this);
      }

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

    Re: Can we make this into a form

    Put your complete midlet and the names of the other classes.There are few doubts.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Registered User
    Join Date
    Feb 2009
    Posts
    7

    Re: Can we make this into a form

    Midlet code
    Last edited by cuteteddy02; 2010-05-05 at 21:17. Reason: error..

  9. #9
    Registered User
    Join Date
    Feb 2009
    Posts
    7

    Re: Can we make this into a form

    Thanks a ton for all your help and time .Waiting for your wonderful pointers.

    Pl. I really need to solve this problem, at this juncture.Sorry, if I've not been quick at understanding the pointers given by you, but I am very new to all this and am trying to learn, The problem is to tackle this assignment at a point when I'm not able to handle it

Similar Threads

  1. how to make EAknSoftkeyBack work in Form view ?
    By nokia_lin in forum Symbian User Interface
    Replies: 4
    Last Post: 2009-07-21, 12:02
  2. Strange problem with compilation!!! ARM9E
    By dmazgalin in forum Symbian
    Replies: 1
    Last Post: 2007-11-02, 09:33
  3. How to make a form go away again?
    By Dankoozy in forum Symbian
    Replies: 1
    Last Post: 2007-06-18, 09:43
  4. Compilation series 60 3rd edition
    By asmobease in forum Symbian Tools & SDKs
    Replies: 32
    Last Post: 2006-09-13, 09:46
  5. Compilation series 60 3rd edition
    By asmobease in forum Symbian
    Replies: 3
    Last Post: 2006-09-10, 14: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
  •  
×