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: 207
Registered: ‎07-31-2009
My Device: Not Specified
Accepted Solution

How to get Id of controls in manager

Hi, 

I am adding a set  controls to a vertical manager iteratively. All the controls are being added to the manager as new instances, as the same set is being added again and again.I need to finally get values from these controls after addition of a certain no of them have been added. I am guessing i would probably need to get some sort of  " id "  if i need to access them. How should i go about it... 

------------------------------------------------------------------------------------------------------------------------
Click the Kudos! badge on left side of the message , if you are happy with a solution given by a user. When you do so, you are saying thanks to its author.
Mark a reply as a solution , if you think your question has been answered.
To mark a message as a solution: Click "Accept as solution" icon on the reply.
Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get Id of controls in manager

you have to store the references of the fields. or access them using the index within their manager (getField(5) for example).
----------------------------------------------------------
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: 207
Registered: ‎07-31-2009
My Device: Not Specified

Re: How to get Id of controls in manager

I can get from the index if i want to get it for the first instance of addition of the controls. But the next time the set of controls get added , the manager wil contain only the values of the new instance of the controls that were created .

- any other ideas?? 

------------------------------------------------------------------------------------------------------------------------
Click the Kudos! badge on left side of the message , if you are happy with a solution given by a user. When you do so, you are saying thanks to its author.
Mark a reply as a solution , if you think your question has been answered.
To mark a message as a solution: Click "Accept as solution" icon on the reply.
Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get Id of controls in manager

i don't understand you.
you want to get a value from a field. this field is added to a manager/screen. this means you can get a reference to the field from the manager/screen and call getText/value/whatever.
----------------------------------------------------------
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: 207
Registered: ‎07-31-2009
My Device: Not Specified

Re: How to get Id of controls in manager

To better explain the problem-  I am trying to replicate the .Net Data repeater control. But since there is no such thing here i had to improvise. I ve used a vertical manager to add a set of controls on the click of a button(replicating a table , where rows are added dynamically). As and when the button is clicked the same set of controls get created again. They are just new instances that are being added. So if i were to try to access the controls on the basis of the index all i would get would be the last instance of the controls( or the values of the controls that were last added.. ) .  
------------------------------------------------------------------------------------------------------------------------
Click the Kudos! badge on left side of the message , if you are happy with a solution given by a user. When you do so, you are saying thanks to its author.
Mark a reply as a solution , if you think your question has been answered.
To mark a message as a solution: Click "Accept as solution" icon on the reply.
Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get Id of controls in manager

as long as the field is added to the screen you can retrieve it from the screen.

call 100 times add(new EditField()), for example, and you can retrieve them by using getField(0) to getField(99).
----------------------------------------------------------
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: 207
Registered: ‎07-31-2009
My Device: Not Specified

Re: How to get Id of controls in manager

This should probably explain it in a better way.. 1.jpg

2.jpg 

------------------------------------------------------------------------------------------------------------------------
Click the Kudos! badge on left side of the message , if you are happy with a solution given by a user. When you do so, you are saying thanks to its author.
Mark a reply as a solution , if you think your question has been answered.
To mark a message as a solution: Click "Accept as solution" icon on the reply.
Developer
Posts: 207
Registered: ‎07-31-2009
My Device: Not Specified

Re: How to get Id of controls in manager

2.jpg11.jpg
------------------------------------------------------------------------------------------------------------------------
Click the Kudos! badge on left side of the message , if you are happy with a solution given by a user. When you do so, you are saying thanks to its author.
Mark a reply as a solution , if you think your question has been answered.
To mark a message as a solution: Click "Accept as solution" icon on the reply.
Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get Id of controls in manager

you have a screen instance. a screen is a manager, so you can execute getField(int index).
you have a manager that represents one of your data sets. these are added to the screen when you press your button.
getField(0) returns the first manager, getField(1) the second.

feel free to store them in a data structure for better access - but you CAN access them from the screen.
open the screen in a debugger window to see its structure more clearly.
----------------------------------------------------------
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: 207
Registered: ‎07-31-2009
My Device: Not Specified

Re: How to get Id of controls in manager

Excellent .. I dint think of it that way.. Anyways thanks a lot. 
------------------------------------------------------------------------------------------------------------------------
Click the Kudos! badge on left side of the message , if you are happy with a solution given by a user. When you do so, you are saying thanks to its author.
Mark a reply as a solution , if you think your question has been answered.
To mark a message as a solution: Click "Accept as solution" icon on the reply.