Getting ItemStateChanged from more than one form

Is this a bug in the MOTOROKR E6 or am I missing something? Advice from experienced coders would be really appreciated.

My MIDlet has to detect itemStateChanged for any item in the current form (Form1 or Form2 in the example) and update a ticker common to both the forms.

Works fine in any emulator including MOTOROKR_E6_E6e emulator.

Works fine in Sony Ericsson k700i even when built using Motorola SDK for Linux products.

On MOTOROKR E6, after once changing to Form2 and back to Form1, Form1 no longer detects itemStateChanged when typing a new value in textField1.

Please advise any workaround, I need to collect data from 2 forms, if I have to include all the fields on one form it would recult in unacceptable amount of scrolling down to get at the fields. The ticker has to be updated immediately when values are changed in either form.

Code appended below, IDE used was NetBeans 5.5.

Thanks in advance, Darryl

/*

* BugReport.java

*

*/

package BugReport;

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

publicclass BugReportextends MIDletimplements CommandListener, ItemStateListener{

public BugReport(){

initialize();

}

private Form form1;

private Form form2;

private Command exitCommand1;

private Command exitCommand2;

private Command screenCommand1;

private TextField textField1;

private TextField textField2;

private Ticker ticker1;

publicvoid commandAction(Command command, Displayable displayable){

if (displayable == form2){

if (command == exitCommand2){

getDisplay().setCurrent(get_form1());

form1.setItemStateListener(this);

}

}elseif (displayable == form1){

if (command == screenCommand1){

getDisplay().setCurrent(get_form2());

form2.setItemStateListener(this);

}elseif (command == exitCommand1){

exitMIDlet();

}

}

}

privatevoid initialize(){

getDisplay().setCurrent(get_form1());

}

public Display getDisplay(){

return Display.getDisplay(this);

}

publicvoid exitMIDlet(){

getDisplay().setCurrent(null);

destroyApp(true);

notifyDestroyed();

}

public Form get_form1(){

if (form1 ==null){

form1 =new Form(null,new Item[]{get_textField1()});

form1.addCommand(get_exitCommand1());

form1.addCommand(get_screenCommand1());

form1.setCommandListener(this);

form1.setTicker(get_ticker1());

form1.setItemStateListener(this);

}

return form1;

}

public Form get_form2(){

if (form2 ==null){

form2 =new Form(null,new Item[]{get_textField2()});

form2.addCommand(get_exitCommand2());

form2.setCommandListener(this);

form2.setTicker(get_ticker1());

}

return form2;

}

public Command get_exitCommand1(){

if (exitCommand1 ==null){

exitCommand1 =new Command("Exit", Command.EXIT, 1);

}

return exitCommand1;

}

public Command get_exitCommand2(){

if (exitCommand2 ==null){

exitCommand2 =new Command("Back","Back to Form1", Command.EXIT, 1);

}

return exitCommand2;

}

public Command get_screenCommand1(){

if (screenCommand1 ==null){

screenCommand1 =new Command("Form2","Show Form2", Command.SCREEN, 1);

}

return screenCommand1;

}

public TextField get_textField1(){

if (textField1 ==null){

textField1 =new TextField("textField1 on Form1", null, 120, TextField.ANY);

}

return textField1;

}

public TextField get_textField2(){

if (textField2 ==null){

textField2 =new TextField("textField2 on Form2", null, 120, TextField.ANY);

}

return textField2;

}

public Ticker get_ticker1(){

if (ticker1 ==null){

ticker1 =new Ticker("Welcome");

}

return ticker1;

}

publicvoid startApp(){

}

publicvoid pauseApp(){

}

publicvoid destroyApp(boolean unconditional){

}

// Everything works fine on any of the emulators

// Tested and works fine on Sony Ericsson k700i

// Buggy omly on M0TOROKR E6

//

publicvoid itemStateChanged(Item item){

// Even this doesn't execute after returning to Form1 from Form2'

ticker1.setString("Some Change");

if (getDisplay().getCurrent() == form1){

// This works fine on first entry to Form1

// but doesn't work after coming back to Form1 from Form2'

ticker1.setString("Change in Form1");

}elseif (getDisplay().getCurrent() == form2){

ticker1.setString("Change in Form2");

}

}

}

[10319 byte] By [Darryl.Burkea] at [2007-11-27 10:36:58]
# 1

OK guys, I've found my workaround.

By using form.set(int itemNum, Item item)

I'm able to reuse the same form and the problem doesn't arise.

Hope my experience is useful to anyone who faces the same bug in any Motorola handset.

Regards, Darryl

Darryl.Burkea at 2007-7-28 18:44:59 > top of Java-index,Java Mobility Forums,Java ME Technologies...