J2ME - sending data from one screen to another (List Selection to populate previous screen)

I am trying to return the value I select from a list to the previous screen.  When I set the myData string during the selection it does not change the field value.  Here is my code:


import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HelloMIDlet extends MIDlet
        implements javax.microedition.lcdui.CommandListener {

    TextField dataEntry;
    Display display;
    Form form;
    Command cancel;
    Command login;
    private List lsDocument;    
    public String myData;
    int count;

    public String getMyData() {
        return myData;

    public void setMyData(String myData) {
        this.myData = myData;

    public HelloMIDlet()
        count = count + 1;
        String s = new Integer(count).toString();
        dataEntry = new TextField("Data Entry:", getMyData().toString(), 10, TextField.ANY);
        form = new Form("Login In");
        login = new Command("Login", Command.OK, 2);

    public void commandAction(Command c, Displayable d) {      
         String label = c.getLabel();    
            if (label.equals("Login"))
            else if (c == List.SELECT_COMMAND)
              switch (lsDocument.getSelectedIndex())
                case 0:
                case 1:
                case 2:
                  //System.out.println("New Element");
    public void startApp() {
        display =  Display.getDisplay(this);

    public void pauseApp() {

    public void destroyApp(boolean unconditional) {
    public void menu()
      String options[] = {" Next", " Previous", " New"};          

      // Create list using arrays, add commands, listen for events
      lsDocument = new List("Document Option:", List.IMPLICIT, options, null);
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You call getMyData() in the Constructor which sets its initial value. If you want that value to change you call setMyData() which you have done. But in order to display the change you need to call getMyData() again at some point after setting it.
So, if you change your first switch case as follows:

case 0:

The word "NEXT" will be displayed in the TextField of your main form.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.