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: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Trouble with custom LabelField

add else { super.fieldChangeNotify(context) } for when your context is not 1.

 

However, what you describe is weird at best. Can you try your previous code on a different API version and check whether it has the same problem there? Looks more like a BlackBerry bug as fieldChangeNotify should do what you are doing manually there (except that it probably checks whether there is any FieldChangeListener registered and only then calls its fieldChanged method).

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Trouble with custom LabelField

Thanks for the tip on the { else }.  I will try out what you asked  and post my results.

Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Trouble with custom LabelField

Adding the else condition seems to start my original problem again...

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Trouble with custom LabelField

If you're controlling all of the uses of the field, reasons you want things to respond to it, and what is going to be setting itself as the change listener, you're probably fine without the call to super.fieldChangeNotify

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Trouble with custom LabelField

 


behrk2 wrote:

Adding the else condition seems to start my original problem again...


 

Can you put a breakpoint in that else branch and see what your context value is when your field is behaving in this weird way? Also check the call stack - you won't see much of the source code but at least class and method names might give you some clue on what is going wrong.

 

Without that else you'll either have to change the call to fieldChangeNotify in ENTER processing to also pass 1 there or your field will never respond to ENTER key.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Trouble with custom LabelField

Interesting...

 

I put a break point on the context in the else statement, and at that point in the code the context has a value of "-2147483648"...

 

Not sure how that is happening.

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Trouble with custom LabelField

Aha! That's FieldChangeListener.PROGRAMMATIC. I'm curious what is programmatically changing your Field... Have you looked at the call stack?

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Trouble with custom LabelField

Yes, I looked at the call stack.  It looks like it is the instantiation of my custom LinkField class that is leading to that context.

 

Here is what my application is doing:

 

1) A screen opens up and an HTTP Request will run - the HTTP Request is retrieving a String from a web service

 

2) When the HTTP Response comes back with the string, then I instantiate LinkField with the String that was returned from the HTTP Response

 

So, the code that I see in the call stack leading up to the context (well, in the classes visible to me at least) is:

 

      super(text, style); // this is in LinkField constructor

 

and before that is the instantiation:

 

      LinkField linkField = new LinkField(response, LinkField.FOCUSABLE |     LinkField.FIELD_HCENTER);

      linkField.setChangeListener(this);

Highlighted
Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: Trouble with custom LabelField

I think I found the culprit: There was an extra linkField.setText("Clear Results...") in my code.  Once I removed that, I was actually able to get rid of the overridden fieldChangeNotify() method and everything seems to be working now...

 

Thank you so much for all of your help!

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Trouble with custom LabelField

OK, that explains it. setText() does change the field programmatically. You really don't want to invoke it inside your FieldChangeListener.fieldChanged!

 

Doesn't this thread demonstrate the differences between finding the cause and treating the symptoms? Smiley Wink

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!