Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
cicube
Posts: 6
Registered: 05-06-2009

ChoiceGroup itemStateChanged fired multiple times bug in BB OS

 Hello,

 Here is the background for the problem: I have a recursive list of hashtables(hashtable inside another hashtable) and a form with a POPUP ChoiceGroup that is initially filled with the keys from the root hashtable. When the user selects a particluar entry a different ChoiceGroup popsup with the keys of the hashtable pointed to by the earlier selection and this goes on till an empty hashtable is found. I have noticed that when the user selects and entry in the root hashtable(or any others for that matter) itemStateChanged is called thrice instead of once.

1. Has anyone encountered this problem?

2. If so, what is the solution?

 

I have included the relevant code below:

-----------------------------------------------------------

 public void itemStateChanged(Item item) {
System.out.println("I am in the Kind References Item state changed method. Kind no is:"+myDaf.kindNo);

isDirty = true;


if (item.getClass() == ChoiceGroup.class) {
ChoiceGroup chg = (ChoiceGroup) item;

boolean[] currentSelection= new boolean[chg.size()];


if(!previousSelectionCreated){
myDaf.previousSelections=new boolean[currentSelection.length];

previousSelectionCreated=true;
}

 

System.out.println("No of items selected is:"+chg.getSelectedFlags(currentSelection));


if(0==chg.getSelectedFlags(currentSelection)){
//Print out the document

 new Echo(this.myDaf.DAFDoc);


this.myDaf.removeChildren(parentPath);
this.myDaf.setPreviousSelection(currentSelection);

isDirty = false; System.out.println("Removed All Children of this kind ref tree");
//Print out the document

 new Echo(this.myDaf.DAFDoc); return;
}

kindFormCurrentItem= this.myDaf.getChangedSelectionIndex(currentSelection);System.

out.println("Kind Form Current Item set to:"+kindFormCurrentItem);
this.handleChoices();

this.myDaf.setPreviousSelection(currentSelection);

 


//Call a new instance of this class again

 if (false==((Hashtable)(this.choiceHashtable.get(chg.getString(chg.getSelectedIndex())))).isEmpty()){


System.out.println("Calling the same class with the next hashtable");
System.out.println("Kind no is:"+myDaf.kindNo);DAKindFormClass nextChoiceList=

new DAKindFormClass("Enter Choice",this.myDaf,(Hashtable) choiceHashtable.get(chg.getString(chg.getSelectedIndex())));
nextChoiceList.clearAndSetupDAKindForm();

nextChoiceList.displayDAKindForm();

}

else{
System.out.println("This hashtable is empty. Kind no is:"+myDaf.kindNo);

this.myDaf.displayDAHeadingForm();
}

}

else

System.out.println("Error Not a kind reference choice group");
}

--------------------------------------------------------------

Please use plain text.