Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 108
Registered: ‎08-05-2008
My Device: Not Specified
Accepted Solution

How to re-initialize an ObjectChoiceField.

I typically initialize an ObjectChoiceField like this:

 

        String [] messages = GetMessageList();
        cboMessages = new ObjectChoiceField("Pick a message", messages );    

        add(cboPrinters);

 

And this works great.  However, later on I want to delete all entries and add a new list to the ObjectChoiceField.

I can't seem to find how to clear the ObjectChoiceField and I also don't see any way to insert new items?

 

Am I missing something massively simple?

Thanks.

Developer
Posts: 19,629
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to re-initialize an ObjectChoiceField.

Try the ObjectChoiceField setChoices(Object[] choices) method, so in your case you would say

cboMessages.setChoices(newList);

 

I generally do an invalidate() after I've done a setChoices(), just to be sure the Field is updated on the screen.

Developer
Posts: 108
Registered: ‎08-05-2008
My Device: Not Specified

Re: How to re-initialize an ObjectChoiceField.

Peter,

 

The ObjectChoiceField does not have an invalidate method.  Do you mean the invalidate method on the form?

Developer
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: How to re-initialize an ObjectChoiceField.

[ Edited ]

Yeah, you can invalidate your Screen.

Message Edited by richard_puckett on 09-17-2008 02:15 PM