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: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

field already added while its already parented Exception in set status

I have a MainScreen where i am setting HFM to setStatus.When i go from screen one to screen two i get this error on set status line

"field already added while its already parented" here is my block of code

 

public MainScreenODP() {
		super(NO_VERTICAL_SCROLL);
		setBanner(PageComponent.logoimage);
		
		if(Constants.tabManager!=null){
			try {
				hfmnew=new HorizontalFieldManager();
				
				hfmnew.add(Constants.tabManager);
				
				setStatus(Constants.tabWidget);
			}
			catch (Exception e) {
			e.printStackTrace();
			}
		}
	}

 What is the problem,can anyone sugges

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: field already added while its already parented Exception in set status

sryy i am setting 

setStatus(hfmnew);

 Any help?

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

Re: field already added while its already parented Exception in set status

Sounds like you are trying to share Constants.tabWidget between the screens, so you only create it once for all your tab screens.  Sorry that doesn't work, you need a separate instance per screen, or remove it and add it for each screen as you move screens. 

 

Summary:  You can't have one Field used in multiple screens.

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: field already added while its already parented Exception in set status

yes,even if i do deleteAll() before adding the constants manager to hfmnew,it still throws the same error

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: field already added while its already parented Exception in set status

i suggest to use debug and call getManager on the field/manager in question, if it is not null you will see where it is added.

if you want a tabbed applicationi would suggest to use a main manager instead of new screens.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: field already added while its already parented Exception in set status

And just to confirm deleteAll only works at a single level of hierarchy.  So if you have a Screen that contains a Manager, and the Manager contains a Field, the deleteAll on the Screen still leaves the Field parented by the Manager.

 

Also deleteAll does not clear the status area.