If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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

Problem identifying the field that gives a value..

[ Edited ]

Hi,

am adding controls to a manager as shown below..ie controls get added as and when the button is clicked.Later on when i want to access each control and get the values , i would like to know which control gave me which value..

 

For Eg : Say the button gets clicked 10 times..So i ll have   10 choice fields.. when i retrieve the values by iterating through the field manager i need to know if which choice field gave which value. That is if the first choice field has been set with "Choice 1"  and second with "Choice 2" , i need to know that the first choice field gave " Choice 1 ". 

 

Is there a way of setting some label of some kind so that i can just say choicefield with this particular " label " gave me this value or choicefield with this particular  "id "  gave me this value..??? 

 

<CODE>

FieldChangeListener changed= new FieldChangeListener()

 {

     

public void fieldChanged(Field field , int context)

{

 String choices[] = {"Choice1", "Choice2", "Choice3"};

  choiceField = new ObjectChoiceField("Project and Activity :", choices,0, choiceField.FIELD_LEFT);

 

              verticalmanager.add(choiceField); 

}

}

 

button.setChangeListener(changed); 

 

</CODE> 

Message Edited by nirmalsat on 09-23-2009 03:22 PM
------------------------------------------------------------------------------------------------------------------------
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.
Please use plain text.
Developer
simon_hain
Posts: 15,908
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem identifying the field that gives a value..

you can either use the index of the field within the manager or add the fields to an own control data structure.
----------------------------------------------------------
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
Please use plain text.
Developer
nirmalsat
Posts: 207
Registered: ‎07-31-2009
My Device: Not Specified

Re: Problem identifying the field that gives a value..

I dont want to use the index cos the actual application will have too many controls being rendered on button click. Could you please explain the second option that u have mentioned...
------------------------------------------------------------------------------------------------------------------------
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.
Please use plain text.
Developer
simon_hain
Posts: 15,908
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem identifying the field that gives a value..

the index is independent from rendering, you can just ask the clicked field for its index within the containing manager.

if you use a list to save the fields when you add them (add to manager, add to list) you can iterate through it or access it by index (depending on the data structure chosen).

another idea would be to save the index on the field itself, extending the basic field to an own class with the needed attribute
----------------------------------------------------------
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
Please use plain text.
Developer
nirmalsat
Posts: 207
Registered: ‎07-31-2009
My Device: Not Specified

Re: Problem identifying the field that gives a value..

Creating a class on my own , would indeed give me an option to have an identifier of my own.. Excellent..I ll try that out.. I ll get back if i run into problems.. 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.
Please use plain text.