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: 29
Registered: ‎03-10-2011
My Device: Not Specified
Accepted Solution

Reuse a field

hi all,

 

         I am facing a small problem, i have a piece of code that uses a field initially and on button click i am replacing it with another field. Now i want the previous field to be used again on another button click. If i am trying to use it there's an error creeping in. Please help me with this. I tried searching it in forums but couldnot find anything useful..

 

thanx in advance..

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

Re: Reuse a field

a single field can only be added to a manager once. as long as you delete it you should be able to re-add it again.

"an error" is not very descriptive. most likely it is an illegalstate exception with a detail message telling you what is wrong.
----------------------------------------------------------
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: 29
Registered: ‎03-10-2011
My Device: Not Specified

Re: Reuse a field

thanx simon_hain for your quick response..

 

can anyone please let me know the use of setting a field DIRTY?? i couldnot understand the exact use of this method.

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

Re: Reuse a field

[ Edited ]

If you wish to reuse a Field, then remove it from its current Manager first.

 

Assume the Field is called myField, then the following code will remove it from its current manager if it has one:

 

Manager m = myField.getManager();

if ( m != null ) {

m.delete(myField);

}

 

dirty fields are ones that have changed, this can be used as an indication that the data on the screen is different to that which was initially displayed, and so the data on the screen needs to be saved.  At least that is how I use it. 

Developer
Posts: 29
Registered: ‎03-10-2011
My Device: Not Specified

Re: Reuse a field

hi peter,

 

          Thanx for the reply. It helped me alot..

 

-Rohit