SetDefaultCommand is not working!

Hi, I must add a command on a ChoiceGroup and set it as the default command to be able to show my command on the phone screen instead of "Select", ok I created the command added to the ChoiceGroup and setDefaulCommand to my command, but when running the app it is not set as the default command. I mean the select command is present on the okay button.

Any clue? how can I fix this.

[395 byte] By [MelGohana] at [2007-11-27 5:57:47]
# 1

Hi,

The default command stuff has been a while for me, but I remember that -- in case of the select command -- you have to remove it before adding / setting another new default command.

I believe you can find some info in the MIDP2.0 Javadoc as well. Read the section "Commands" in the Item class description. See the following sentence how to remove the default command:

An Item may be set to have no default Command by removing it from the Item or by passing null to the setDefaultCommand() method.

When having removed the default command you should be able to specify a new default command without problems.

Good luck!

Ciao,

Jasper

jappersa at 2007-7-12 16:31:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

No, its not working. this is what I did:

articulos=new ChoiceGroup ("Art韈ulos del pedido (codigo, nombre, cantidad, precio)", Choice.EXCLUSIVE);

articulos.setDefaultCommand (null);

articulos.setDefaultCommand (editarPedidoRevision);

and is just the same.

I also removed the default Command without adding a new one to have no default, but it is the same, the select Command is being displayed.

Why does this doesnt work as the API says!

MelGohana at 2007-7-12 16:31:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

Did you perform tests on target and emulator?

What does the following do?

articulos.setDefaultCommand (null);

articulos.removeCommand(Command.ITEM);

articulos.setDefaultCommand (editarPedidoRevision);

It's just a suggestion, I have no idea if that would work for you.

Jasper

jappersa at 2007-7-12 16:31:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
The remove Command take a Command as paarmeter not an int.It could be easy if I could get a reference to the defaultCommand to be able to remove it. But I cant.I am testing on the real device because the emulator doesnt show a real behavior with real components.
MelGohana at 2007-7-12 16:31:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5

Ah yeah, I got confused. I was wrong, that would only work for List implementations, because there you will have the final SELECT_COMMAND, which can be removed and overloaded by some custom command.

I remember now that I had similar problems years ago. I guess we decided to leave that out, simply because there are no suitable API calls available.

Is there no other way for what you want to realise? It might also be an option to implement a ChoiceGroup on your own by using a CustomItem. However, if time is critical in your project, it isn't a wise idea, because it will be a lot of work...

jappersa at 2007-7-12 16:31:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6
Hi Jassper, in fact I am already doing the CustomItem, and doesnt seems to be too complicated as a normal ChoiceGroup, but I want to define somw custom behavior that is complicated so I guess it will be finished for tomorrow.
MelGohana at 2007-7-12 16:31:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7
Okay, that sounds great! Good luck!At least you found a solution to bypass one of those strange things in the mighty world of MIDP. :-)
jappersa at 2007-7-12 16:31:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...