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
Regular Contributor
Posts: 61
Registered: ‎02-24-2010
My Device: Storm 2
My Carrier: AT&T

Please explain the fieldchangenotify() function

Hi..

 

 

Please explain the the fieldchangenotify(int context) function... 

 

what does this function actually do and when it is used and whats the concept of context here ??

 

 

Thanx

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Please explain the fieldchangenotify() function

This method belongs to the interface FieldChangeListener. You implement this interface in your class, in order to be notified when the contents of a field is changed.  You then pass a reference of your listener implementation to the field in question using Field.setChangeLIstener(). Now your method is called whenever the value of the field is changed.

 

All of this is in the javadocs.

 

Have you looked at the sample programs that ship with the JDE? I would certainly advise this.

 

 

 

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

Re: Please explain the fieldchangenotify() function

I wonder if RexDoug is explaining

 

public void fieldChanged(Field field, int context)

 

rather than

 

protected void fieldChangeNotify(int context)

 

fieldChangeNotify is a method on the Field class.

 

Other processing for the Field should call this when they change the state of the Field in a way that a FieldChangeListener might be interested in seeing. 

 

Mostly you do not need to override this function, but you can call it.  Specifically if you are creating your won Field, then you will probably want to call it when you know the Field's state as changed.  For example, if you create a Custom Button, and your processing pricks up and processes a navigationClick, then you should call fieldChangeNotify() to tell any listener that the button has been clicked. 

 

When you call fieldChangeNotify you can pass a context that can be used by the FieldChangeListener to identify what caused the Field to change - and they can query the Field to determine its current state. 

 

If you are not bothered about FieldChangeListeners you can completely ignore this method.

 

Hope that is clear and I've answered the right question. 

 

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Please explain the fieldchangenotify() function

oops....thanks Peter - I believe you are correct.

 

Probably would have been the next question, anyway :smileyhappy: